Hey fellows, i got over my problem with displaying an icon in a dialogbox, now i wanna go a step farther, is it possible to use the icons specified in the windows.inc of masm32 to be the application icon or to show it in a dialogbox. what i mean are those like MB_ICONWARNING and so on, u guys have any suggestions ? Thanks Regards Typhoon
Posted on 2001-03-27 00:10:00 by Typhoon
here are the icon constants you can use: IDI_APPLICATION Default application icon. IDI_ASTERISK Same as IDI_INFORMATION. IDI_ERROR Hand-shaped icon. IDI_EXCLAMATION Same as IDI_WARNING. IDI_HAND Same as IDI_ERROR. IDI_INFORMATION Asterisk icon. IDI_QUESTION Question mark icon. IDI_WARNING Exclamation point icon. IDI_WINLOGO Windows logo icon. just invoke as usual such as invoke loadicon,window_handle,IDI_WARNING
Posted on 2001-03-27 02:46:00 by smurf
ok that works good, but is it possible to do the same thing in a resourcefile ? like this code: #define ICON_WARNING 3004 ICON_WARNING ICON "warning.ico" to show the icon CONTROL ICON_WARNING, -1, "static", SS_ICON | WS_CHILD | WS_VISIBLE, 10, 25, 0, 0 So instead of "warning.ico" maybe like IDI_WARNING ? i don't find a way to do that Regards Typhoon
Posted on 2001-03-27 03:01:00 by Typhoon
not sure if your wondering about a custom icon. if you are here is my source code. all you need to do is change the icon you have to skull.ico
.386
.model flat,stdcall
option casemap:none

WinMain proto :DWORD,:DWORD,:DWORD,:DWORD

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\gdi32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\gdi32.lib

.const
IDI_ICON1       equ 5

.data
ClassName db "SimpleWinClass",0
AppName  db "Icon",0

.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
hwnd HWND ?

.code
start:
	invoke GetModuleHandle, NULL
	mov    hInstance,eax
	invoke GetCommandLine
	mov    CommandLine,eax
	invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
	invoke ExitProcess,eax
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
	LOCAL wc:WNDCLASSEX
	LOCAL msg:MSG
        mov   wc.cbSize,SIZEOF WNDCLASSEX
	mov   wc.style, CS_HREDRAW or CS_VREDRAW
	mov   wc.lpfnWndProc, OFFSET WndProc
	mov   wc.cbClsExtra,NULL
	mov   wc.cbWndExtra,NULL
        push  hInstance
        pop   wc.hInstance
        invoke LoadIcon, hInstance, IDI_ICON1
        mov   wc.hIcon,eax
	mov   wc.hbrBackground,COLOR_WINDOW+1
	mov   wc.lpszMenuName,NULL
	mov   wc.lpszClassName,OFFSET ClassName
	invoke LoadIcon,NULL,IDI_APPLICATION
	invoke LoadCursor,NULL,IDC_ARROW
	mov   wc.hCursor,eax
	invoke RegisterClassEx, addr wc
	INVOKE CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\
                           WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\
                           CW_USEDEFAULT,300,200,NULL,NULL,\
                           hInst,NULL
	mov   hwnd,eax
	invoke ShowWindow, hwnd,SW_SHOWNORMAL
	invoke UpdateWindow, hwnd
	.WHILE TRUE
		invoke GetMessage, ADDR msg,NULL,0,0
		.BREAK .IF (!eax)
		invoke TranslateMessage, ADDR msg
		invoke DispatchMessage, ADDR msg
	.ENDW
	mov eax,msg.wParam
	ret
WinMain endp

WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
	LOCAL ps:PAINTSTRUCT
        .IF uMsg==WM_DESTROY
		invoke PostQuitMessage,NULL
        .ELSEIF eax==WM_PAINT
                invoke BeginPaint,hWnd, ADDR ps
                invoke EndPaint,hWnd, ADDR ps
	.ELSE
		invoke DefWindowProc,hWnd,uMsg,wParam,lParam		
		ret
	.ENDIF
	xor eax,eax
	ret
WndProc endp
end start
##############################################################
#################### RESOURCE FILE ###########################
##############################################################

#define IDI_ICON1 5

IDI_ICON1 ICON DISCARDABLE MOVEABLE LOADONCALL "skull.ico"
Posted on 2001-03-27 03:23:00 by smurf
Smurf, you call your dialog box via a windowclass procedure i called mine via a dialog box procedure so i don't have the chance to set the icon i'm trying to get it done over a resource file your last line in the resource file contains an icon in a separate file, that is being include while compiling I wanna use the standard icons, given in resource.h and windows.inc (the once you showed me) so instead of "skull.ico" i want maybe just IDI_WARNING i figured out how it works putting it into the dialogbox: CONTROL IDI_WARNING,-1,"static".... But i'm not able to get it as the standard icon for the application You have a way to do that ?
Posted on 2001-03-27 03:49:00 by Typhoon
would you mind posting your full code? smurf
Posted on 2001-03-27 03:55:00 by smurf
no problem, gimme a sec
Posted on 2001-03-27 04:02:00 by Typhoon
.386 .model flat,stdcall option casemap:none DlgProc proto :DWORD,:DWORD,:DWORD,:DWORD include \masm32\include\windows.inc include \masm32\include\user32.inc include \masm32\include\kernel32.inc includelib \masm32\lib\user32.lib includelib \masm32\lib\kernel32.lib .data DlgName db "Buba",0 ButtonClass db "button",0 .data? hInstance HINSTANCE ? hwndButton HWND ? .const IDC_YES equ 3001 IDC_NO1 equ 3002 IDC_NO2 equ 3003 .code start: invoke GetModuleHandle, NULL mov hInstance,eax invoke DialogBoxParam, hInstance, ADDR DlgName,NULL, addr DlgProc, NULL invoke ExitProcess,eax DlgProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM .IF uMsg==WM_CLOSE invoke EndDialog, hWnd,NULL .ELSEIF uMsg==WM_INITDIALOG invoke GetDlgItem, hWnd, IDC_NO1 invoke ShowWindow, eax, SW_HIDE invoke SendMessage,hWnd,WM_SETICON,NULL,IDI_WARNING .ELSEIF uMsg==WM_COMMAND mov eax,wParam mov edx,wParam shr edx,16 .IF dx==BN_CLICKED .IF ax==IDC_YES invoke EndDialog, hWnd,NULL .ELSEIF ax==IDC_NO1 invoke GetDlgItem, hWnd, IDC_NO1 invoke ShowWindow, eax, SW_HIDE invoke GetDlgItem, hWnd, IDC_NO2 invoke ShowWindow, eax, SW_SHOW .ELSEIF ax==IDC_NO2 invoke GetDlgItem, hWnd, IDC_NO2 invoke ShowWindow, eax, SW_HIDE invoke GetDlgItem, hWnd, IDC_NO1 invoke ShowWindow, eax, SW_SHOW .ENDIF .ENDIF .ELSE mov eax,FALSE ret .ENDIF mov eax,TRUE ret DlgProc endp end start Resource: #include "\masm32\include\resource.h" #define IDC_YES 3001 #define IDC_NO1 3002 #define IDC_NO2 3003 Buba DIALOG LOADONCALL PURE 10, 10, 205, 60 STYLE 0x0004 | DS_CENTER | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU | WS_VISIBLE | WS_OVERLAPPED | DS_MODALFRAME | DS_3DLOOK CAPTION "Windows Protection Error" FONT 10, "Arial" BEGIN CONTROL IDI_WARNING, -1, "static", SS_ICON | WS_CHILD | WS_VISIBLE, 10, 25, 0, 0 DEFPUSHBUTTON "No", IDC_NO1, 25,40,35,13, DEFPUSHBUTTON "No", IDC_NO2, 145,40,35,13 DEFPUSHBUTTON "Yes", IDC_YES, 85,40,35,13 CTEXT "bla bla", -1, 22, 9, 160, 8 CTEXT "bla bla", -1, 22, 20, 160, 8 END I read in Iczelions tuts that u can set the icon by sending the WM_SETICON message to the dialog procedure during Initiating please check if i did that right I'm a real greehorn :)
Posted on 2001-03-27 04:06:00 by Typhoon
Typhoon, Have a look at the MASM32 example code for "resdlg2". It loads an icon for a modal dialog box in the normal manner. To display an icon in the client area of the dialog, set a static window with the correct style and set the icon for it in you resource editor. Most will do that OK. Regards, hutch@pbq.com.au
Posted on 2001-03-27 04:39:00 by hutch--
hey fellows, thanks for the ideas, i got it figured out how i put the icon into the caption bar, but now it isn't the standard icon for the application i added following to the WM_INITDIALOG Section\ invoke LoadIcon,NULL,IDI_WARNING mov hIcon, eax invoke SendMessage,hWnd,WM_SETICON,1,hIcon but how do i get it to be the standard application icon, at the moment it is just that one for executable files. when i was doing it through the icon resource in the resource file it worked, it was the standard but now it doesn't Regards Typhoon
Posted on 2001-03-27 15:00:00 by Typhoon
change your this line: invoke LoadIcon,NULL,IDI_WARNING to: invoke LoadIcon,NULL,IDI_APPLICATION
Posted on 2001-03-27 15:29:00 by smurf
Sorry smurf that wont work, it only changes the icon shown in the caption bar but doesn't effect the icon shown in for example the windows explorer
Posted on 2001-03-27 15:31:00 by Typhoon
can you send me your source code so i can play around with it a bit? smurf@gci.net thanks smurf
Posted on 2001-03-27 16:05:00 by smurf
I don't think you can get it to show as the default Icon in windows explorer. you see the system ICONS are showed by windows when your program runs. it is not in the exe file at all, and windows explorer shows the lowest numbered ICON as that exe's Icon. the best way to do it is to make an ICON that look just like the one your using from windows. I happen to have all the windows system ICONs as real ICO's Hope this helps.... This message was edited by Zcoder, on 3/28/2001 11:09:25 AM
Posted on 2001-03-28 10:06:00 by Zcoder
Thanks, sounds good, i'll try that.
Posted on 2001-03-28 23:06:00 by Typhoon