flat assembler
Message board for the users of flat assembler.
Index
> Windows > Icon Trouble |
Author |
|
shism2 03 Jan 2006, 18:31
mov eax,[uMsg]
cmp eax,WM_INITDIALOG jne @WM_COMMAND_MINIMIZED invoke LoadIcon,[hInstance],IDI_ICON invoke SendMessage,[hWin],WM_SETICON,TRUE,eax |
|||
03 Jan 2006, 18:31 |
|
calpol2004 03 Jan 2006, 18:45
hmm i tried ure code except i got errors with the compare and jump. i left them out and this happened:
1.the title of window was shifted to right as if the icon was there 2.there is no icon!
|
||||||||||
03 Jan 2006, 18:45 |
|
shism2 04 Jan 2006, 00:21
Did you define IDI_ICON???? to something????
If so, post your code and executable. I will fix the problem for you |
|||
04 Jan 2006, 00:21 |
|
calpol2004 04 Jan 2006, 11:54
ok here my code . i have assigned an icon to ID_ICON as it the icon of the application when viewed in a folder, but it doesnt appear in top left corner of the dialog.
Code: format PE GUI 4.0 entry start include '..\..\include\win32a.inc' ID_ICON = 1 ID_USERNAME = 100 ID_MESSAGE = 101 ID_SEND = 102 ID_CLEAR = 103 section '.data?' data readable writeable flags dd ? message dd ? length rd 1 sender rd 21 username rd 21 path dd "send",0 open dd "open",0 net dd "net",0 section '.code' code readable executable start: invoke GetModuleHandle,0 invoke DialogBoxParam,eax,37,HWND_DESKTOP,DialogProc,0 or eax,eax jz exit exit: invoke ExitProcess,0 proc DialogProc hwnddlg,msg,wparam,lparam push ebx esi edi cmp [msg],WM_INITDIALOG je wminitdialog cmp [msg],WM_COMMAND je wmcommand cmp [msg],WM_CLOSE je wmclose xor eax,eax jmp finish wminitdialog: invoke SetWindowPos,[hwnddlg],HWND_TOPMOST,0,0,0,0,SWP_NOMOVE+SWP_NOSIZE invoke GetModuleHandle,0 invoke LoadIcon,eax,ID_ICON mov eax,[msg] invoke SendMessage,[hwnddlg],WM_SETICON,ICON_SMALL,eax jmp processed wmcommand: mov eax,[wparam] and eax,0FFFFh cmp eax,ID_SEND je send cmp eax,ID_CLEAR je clear jmp processed send: invoke GetUserName,sender,length+20 invoke GetDlgItemText,[hwnddlg],ID_USERNAME,username,length+20 invoke GetDlgItemText,[hwnddlg],ID_MESSAGE,message,length+449 ;concenate strings here invoke ShellExecute,[hwnddlg],open,net,path,0,SW_HIDE invoke MessageBox,[hwnddlg],path,message,MB_OK jmp processed clear: invoke SetDlgItemText,[hwnddlg],ID_USERNAME,"" invoke SetDlgItemText,[hwnddlg],ID_MESSAGE,"" jmp processed wmclose: invoke EndDialog,[hwnddlg],0 processed: mov eax,1 finish: pop edi esi ebx ret endp section '.idata' import data readable writeable library kernel,'KERNEL32.DLL',user,'USER32.DLL',shell,'SHELL32.DLL',advapi,'ADVAPI32.DLL' import kernel,GetModuleHandle,'GetModuleHandleA',ExitProcess,'ExitProcess' import user,DialogBoxParam,'DialogBoxParamA',GetDlgItemText,'GetDlgItemTextA',\ SetDlgItemText,'SetDlgItemTextA',MessageBox,'MessageBoxA',EndDialog,'EndDialog',\ SetWindowPos,'SetWindowPos',SendMessage,'SendMessageA',LoadIcon,'LoadIconA' import shell,ShellExecute,'ShellExecuteA' import advapi,GetUserName,'GetUserNameA' section '.rsrc' resource data readable directory RT_DIALOG,dialogs,RT_ICON,icons,RT_GROUP_ICON,group_icons resource icons,1,LANG_NEUTRAL,icon_data resource group_icons,17,LANG_NEUTRAL,main_icon icon main_icon,icon_data,'icon.ico' resource dialogs,37,LANG_ENGLISH+SUBLANG_DEFAULT,messager dialog messager,'Messenger',340,280,180,55,DS_MODALFRAME+DS_CENTER+WS_POPUP+WS_CAPTION+WS_SYSMENU+WS_MINIMIZEBOX dialogitem 'EDIT','Insert Username Here',ID_USERNAME,2,5,121,15,WS_VISIBLE+WS_BORDER+WS_TABSTOP dialogitem 'EDIT','Insert Message Here',ID_MESSAGE,2,25,121,15,WS_VISIBLE+WS_BORDER+WS_TABSTOP+ES_AUTOHSCROLL dialogitem 'BUTTON','Send',ID_SEND,125,5,52,15,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON dialogitem 'BUTTON','Clear',ID_CLEAR,125,25,52,15,WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON dialogitem 'STATIC','Created By Callum Lamb',-1,54,46,100,9,WS_VISIBLE enddialog
|
|||||||||||
04 Jan 2006, 11:54 |
|
calpol2004 04 Jan 2006, 14:05
i accidentally pressed new thread instead of reply so it took me a while to realise and put here where it shud be . but heres my code i have assigned an icon to ID_ICON ne ways heres my source see if u can see any problems.
Code: format PE GUI 4.0 entry start include '..\..\include\win32a.inc' ID_ICON = 1 ID_USERNAME = 100 ID_MESSAGE = 101 ID_SEND = 102 ID_CLEAR = 103 section '.data?' data readable writeable flags dd ? message dd ? length rd 1 sender rd 21 username rd 21 path dd "send",0 open dd "open",0 net dd "net",0 section '.code' code readable executable start: invoke GetModuleHandle,0 invoke DialogBoxParam,eax,37,HWND_DESKTOP,DialogProc,0 or eax,eax jz exit exit: invoke ExitProcess,0 proc DialogProc hwnddlg,msg,wparam,lparam push ebx esi edi cmp [msg],WM_INITDIALOG je wminitdialog cmp [msg],WM_COMMAND je wmcommand cmp [msg],WM_CLOSE je wmclose xor eax,eax jmp finish wminitdialog: invoke SetWindowPos,[hwnddlg],HWND_TOPMOST,0,0,0,0,SWP_NOMOVE+SWP_NOSIZE invoke GetModuleHandle,0 invoke LoadIcon,eax,ID_ICON mov eax,[msg] invoke SendMessage,[hwnddlg],WM_SETICON,ICON_SMALL,eax jmp processed wmcommand: mov eax,[wparam] and eax,0FFFFh cmp eax,ID_SEND je send cmp eax,ID_CLEAR je clear jmp processed send: invoke GetUserName,sender,length+20 invoke GetDlgItemText,[hwnddlg],ID_USERNAME,username,length+20 invoke GetDlgItemText,[hwnddlg],ID_MESSAGE,message,length+449 ;concenate strings here invoke ShellExecute,[hwnddlg],open,net,path,0,SW_HIDE invoke MessageBox,[hwnddlg],path,message,MB_OK jmp processed clear: invoke SetDlgItemText,[hwnddlg],ID_USERNAME,"" invoke SetDlgItemText,[hwnddlg],ID_MESSAGE,"" jmp processed wmclose: invoke EndDialog,[hwnddlg],0 processed: mov eax,1 finish: pop edi esi ebx ret endp section '.idata' import data readable writeable library kernel,'KERNEL32.DLL',user,'USER32.DLL',shell,'SHELL32.DLL',advapi,'ADVAPI32.DLL' import kernel,GetModuleHandle,'GetModuleHandleA',ExitProcess,'ExitProcess' import user,DialogBoxParam,'DialogBoxParamA',GetDlgItemText,'GetDlgItemTextA',\ SetDlgItemText,'SetDlgItemTextA',MessageBox,'MessageBoxA',EndDialog,'EndDialog',\ SetWindowPos,'SetWindowPos',SendMessage,'SendMessageA',LoadIcon,'LoadIconA' import shell,ShellExecute,'ShellExecuteA' import advapi,GetUserName,'GetUserNameA' section '.rsrc' resource data readable directory RT_DIALOG,dialogs,RT_ICON,icons,RT_GROUP_ICON,group_icons resource icons,1,LANG_NEUTRAL,icon_data resource group_icons,17,LANG_NEUTRAL,main_icon icon main_icon,icon_data,'icon.ico' resource dialogs,37,LANG_ENGLISH+SUBLANG_DEFAULT,messager dialog messager,'Messenger',340,280,180,55,DS_MODALFRAME+DS_CENTER+WS_POPUP+WS_CAPTION+WS_SYSMENU+WS_MINIMIZEBOX dialogitem 'EDIT','Insert Username Here',ID_USERNAME,2,5,121,15,WS_VISIBLE+WS_BORDER+WS_TABSTOP dialogitem 'EDIT','Insert Message Here',ID_MESSAGE,2,25,121,15,WS_VISIBLE+WS_BORDER+WS_TABSTOP+ES_AUTOHSCROLL dialogitem 'BUTTON','Send',ID_SEND,125,5,52,15,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON dialogitem 'BUTTON','Clear',ID_CLEAR,125,25,52,15,WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON dialogitem 'STATIC','Created By Callum Lamb',-1,54,46,100,9,WS_VISIBLE enddialog and heres the whole package:
|
|||||||||||
04 Jan 2006, 14:05 |
|
Reverend 04 Jan 2006, 15:56
Code: invoke GetModuleHandle,0 invoke LoadIcon,eax,ID_ICON mov eax,[msg] invoke SendMessage,[hwnddlg],WM_SETICON,ICON_SMALL,eax 1. First of all. What does this "mov eax, [msg]" do here in the middle of other code? The point here is not to overwrite eax. Delete that line 2. Afaik, you pass RT_GROUP_ICON id to LoadIcon API not RT_ICON itself. Try "invoke LoadIcon, eax, 17" |
|||
04 Jan 2006, 15:56 |
|
calpol2004 04 Jan 2006, 18:06
wow thx, works great, however im havin problems with the actual icons. it always assigns the first icon in the icon file to the top left corner (small 16x16) and the same in a winxp folder (supposed to be large 48x48) and also on desktop (32x32). say if i set my icon to a 16x16 or have 16x16 first in the icon file, small icons will be ok but 32x32 and 48x48 look weird as they show a rather enlarged pixelated icon even though i have 32x32 and 48x48 versions inside the icon files, and vice versa how can i make the application recognise all the icons in the icon file and display them appropriately instead of setting one icon for everything?
|
|||
04 Jan 2006, 18:06 |
|
farrier 04 Jan 2006, 20:57
calpol2004,
The following works for me with an app that has a dialog as the main window: Code: WindowsDir rb MAX_PATH invoke GetModuleFileName, NULL, WindowsDir, MAX_PATH ;Retrieve fully qualified exe name invoke ExtractIcon, [gWnd], WindowsDir, 0 ;gets handle to icon from exe mov [icon_hand], eax push eax invoke SendMessage, [gWnd], WM_SETICON, ICON_SMALL, eax pop eax invoke SendMessage, [gWnd], WM_SETICON, ICON_BIG, eax hth, farrier _________________ Some Assembly Required It's a good day to code! U.S.Constitution; Bill of Rights; Amendment 1: ... the right of the people peaceably to assemble, ... The code is dark, and full of errors! |
|||
04 Jan 2006, 20:57 |
|
Reverend 04 Jan 2006, 21:31
farrier: Maybe it works, but it's very unclean solution. I wouldn't involve SHELL32.DLL (ie. ExtractIcon API) at all. It's better to search for an error in previous code.
I already did this and answered in another thread. EAX is overwritten after calling for icon handle. Also bad resource id is passed |
|||
04 Jan 2006, 21:31 |
|
shism2 05 Jan 2006, 04:40
Code: format PE GUI 4.0 entry start include '..\..\include\win32a.inc' ID_ICON = 1 ID_MAINDLG = 37 ID_USERNAME = 100 ID_MESSAGE = 101 ID_SEND = 102 ID_CLEAR = 103 ____MACRO_______________ macro @GetModuleHandle { mov eax,dword [fs:18h] ; API : GetModuleHandleA mov eax,dword [ds:eax+30h] ;--------------- mov eax,dword [ds:eax+8h] ;-------------------- } section '.data?' data readable writeable flags dd ? message dd ? hInstance dd ? length rd 1 sender rd 21 username rd 21 path dd "send",0 open dd "open",0 net dd "net",0 section '.code' code readable executable start: @GetModuleHandle mov [hInstance],eax invoke DialogBoxParam,eax,ID_MAINDLG ,HWND_DESKTOP,DialogProc,0 test eax,eax jz exit exit: invoke ExitProcess,0 proc DialogProc hwnddlg,msg,wparam,lparam push ebx esi edi cmp [msg],WM_INITDIALOG je wminitdialog cmp [msg],WM_COMMAND je wmcommand cmp [msg],WM_CLOSE je wmclose xor eax,eax jmp finish wminitdialog: invoke SetWindowPos,[hwnddlg],HWND_TOPMOST,0,0,0,0,SWP_NOMOVE+SWP_NOSIZE invoke LoadIcon,[hInstance],ID_ICON invoke SendMessage,[hwnddlg],WM_SETICON,ICON_SMALL,eax jmp processed wmcommand: mov eax,[wparam] and eax,0FFFFh cmp eax,ID_SEND je send cmp eax,ID_CLEAR je clear jmp processed send: invoke GetUserName,sender,length+20 invoke GetDlgItemText,[hwnddlg],ID_USERNAME,username,length+20 invoke GetDlgItemText,[hwnddlg],ID_MESSAGE,message,length+449 ;concenate strings here invoke ShellExecute,[hwnddlg],open,net,path,0,SW_HIDE invoke MessageBox,[hwnddlg],path,message,MB_OK jmp processed clear: invoke SetDlgItemText,[hwnddlg],ID_USERNAME,"" invoke SetDlgItemText,[hwnddlg],ID_MESSAGE,"" jmp processed wmclose: invoke EndDialog,[hwnddlg],0 processed: mov eax,1 finish: pop edi esi ebx ret endp section '.idata' import data readable writeable library kernel,'KERNEL32.DLL',user,'USER32.DLL',shell,'SHELL32.DLL',advapi,'ADVAPI32.DLL' import kernel,GetModuleHandle,'GetModuleHandleA',ExitProcess,'ExitProcess' import user,DialogBoxParam,'DialogBoxParamA',GetDlgItemText,'GetDlgItemTextA',\ SetDlgItemText,'SetDlgItemTextA',MessageBox,'MessageBoxA',EndDialog,'EndDialog',\ SetWindowPos,'SetWindowPos',SendMessage,'SendMessageA',LoadIcon,'LoadIconA' import shell,ShellExecute,'ShellExecuteA' import advapi,GetUserName,'GetUserNameA' section '.rsrc' resource data readable directory RT_DIALOG,dialogs,RT_ICON,icons,RT_GROUP_ICON,group_icons resource icons,1,LANG_NEUTRAL,icon_data resource group_icons,17,LANG_NEUTRAL,main_icon icon main_icon,icon_data,'icon.ico' resource dialogs,37,LANG_ENGLISH+SUBLANG_DEFAULT,messager dialog messager,'Messenger',340,280,180,55,DS_MODALFRAME+DS_CENTER+WS_POPUP+WS_CAPTION+WS_SYSMENU+WS_MINIMIZEBOX dialogitem 'EDIT','Insert Username Here',ID_USERNAME,2,5,121,15,WS_VISIBLE+WS_BORDER+WS_TABSTOP dialogitem 'EDIT','Insert Message Here',ID_MESSAGE,2,25,121,15,WS_VISIBLE+WS_BORDER+WS_TABSTOP+ES_AUTOHSCROLL dialogitem 'BUTTON','Send',ID_SEND,125,5,52,15,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON dialogitem 'BUTTON','Clear',ID_CLEAR,125,25,52,15,WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON dialogitem 'STATIC','Created By Callum Lamb',-1,54,46,100,9,WS_VISIBLE enddialog |
|||
05 Jan 2006, 04:40 |
|
farrier 05 Jan 2006, 13:33
calpol2004,
You can use the "unclean" solution I gave you in "the other" thread using the ExtractIcon function, where you can specify which icon you wish to extract. I've never been referred to as "unclean" before; I guess I'll have to have a talk with my Rabbi/Imam hth, farrier _________________ Some Assembly Required It's a good day to code! U.S.Constitution; Bill of Rights; Amendment 1: ... the right of the people peaceably to assemble, ... The code is dark, and full of errors! |
|||
05 Jan 2006, 13:33 |
|
Reverend 05 Jan 2006, 19:18
farrier wrote: I've never been referred to as "unclean" before; farrier wrote: You can use the "unclean" solution I gave you in "the other" thread using the ExtractIcon function, where you can specify which icon you wish to extract. |
|||
05 Jan 2006, 19:18 |
|
farrier 05 Jan 2006, 20:28
Reverend,
Alright, now he has two ways of accomplishing the same thing. I was kidding! farrier _________________ Some Assembly Required It's a good day to code! U.S.Constitution; Bill of Rights; Amendment 1: ... the right of the people peaceably to assemble, ... The code is dark, and full of errors! |
|||
05 Jan 2006, 20:28 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.