simple Posted August 9, 2015 Posted August 9, 2015 assuming u have only 1 monitor, GetWindowRect() can get the res but setting a value like 9999999 is ok too
Teddy Rogers Posted August 10, 2015 Posted August 10, 2015 For setting window bounds take a look at using WM_GETMINMAXINFO in your window callback events... https://msdn.microsoft.com/en-us/library/windows/desktop/ms632626%28v=vs.85%29.aspx Ted. 1
maluc Posted August 10, 2015 Posted August 10, 2015 Ok thanks again simple it works so far on my first tests only to use WindowSize function.One question about that function.So I just wanna limit the min sizes but not the max sizes (they can be so large as user want or till max screen resolution) so what do I enter there if I wanna set no limit for max?I can enter 99999 for exsample.....so I forgot again the API to get used screen resolution to enter the right actually max W & H or is it no problem to choose any high value as 999999?Just wanna prevent possible problems later thats why I am asking again. greetz MASM .elseif uMsg == WM_GETMINMAXINFO mov eax, lParam mov (MINMAXINFO ptr [eax]).ptMinTrackSize.x, 450 mov (MINMAXINFO ptr [eax]).ptMaxTrackSize.x, 460 mov (MINMAXINFO ptr [eax]).ptMinTrackSize.y, 160 1
simple Posted August 10, 2015 Posted August 10, 2015 forget the code in post55 - WM_GETMINMAXINFO will be faster. in the above code delete the line for ptMaxTrackSize.x for only doing min size. (almost) the same thing is possible in WM_SIZING too. 1
LCF-AT Posted August 10, 2015 Author Posted August 10, 2015 Hi again, thanks for the new info about WM_GETMINMAXINFO + quick example. Works great and also better. greetz
LCF-AT Posted August 11, 2015 Author Posted August 11, 2015 Hi again, ok I have another question. So I have a listview and inside I have stored tons of infos and now I had a idea to add a small search edit control where I can enter letters etc or paste words snippets and the search should start straight right after something was entered or pastet and selection does jump to word what does match.I wrote the code for this already but got problems with using the right WM_XY.First I subclassed this one edit control and in this routine I tried first to use WM_KEYDOWN what als works so far if I enter something but problem is that its just working for each 2. key press.If I enter "z" for exsample then my API with WM_GETTEXT gets nothing into buffer (in wParam I can see z came back) and I don't know why!Just if I press a second time then I get also something in buffer after using WM_GETTEXT so thats the first problem.Now I also tried to use WM_PASTE and there I get same problem at the first time if I paste something into edit control.First time nothing happens and then it works.So WM_GETTEXT dosen't work again on first time and I have no idea why.My code of this looks so now... SEARCH proc hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD local all:DWORD local empty:DWORD LOCAL buffas [256]:BYTE LOCAL buffas2 [256]:BYTE .if uMsg == WM_PASTE || uMsg == WM_KEYDOWN nop invoke RtlZeroMemory,addr buffas, sizeof buffas invoke RtlZeroMemory,addr buffas2, sizeof buffas2 invoke SendMessage,hWnd,WM_GETTEXT,sizeof buffas,addr buffas .if eax != 0h mov edi, eax mov empty, 0h dec empty mov all, 0h invoke SendMessage, LISTVIEW,LVM_GETITEMCOUNT,0,0 .if eax!=0h mov all, eax SELCHECKO_1A: inc empty mov ebx, empty mov lvi6.imask,LVIF_TEXT mov lvi6.iItem,ebx mov lvi6.iSubItem,1 lea eax, buffas2 mov lvi6.pszText, eax mov lvi6.cchTextMax, sizeof buffas2 invoke SendMessage,LISTVIEW, LVM_GETITEMTEXT, ebx, addr lvi6 invoke CompareString,0,NORM_IGNORECASE,addr buffas,edi,addr buffas2,edi .if eax!=2h mov eax, empty cmp eax, all jb SELCHECKO_1A .else mov lvi6.imask,LVIF_STATE mov lvi6.state,0 mov lvi6.stateMask, LVIS_SELECTED or LVIS_FOCUSED invoke SendMessage,LISTVIEW,LVM_SETITEMSTATE,-1, addr lvi6 mov lvi6.state,LVIS_SELECTED or LVIS_FOCUSED mov lvi6.stateMask, LVIS_SELECTED or LVIS_FOCUSED invoke SendMessage,LISTVIEW,LVM_SETITEMSTATE,empty, addr lvi6 invoke SendMessage,LISTVIEW,LVM_ENSUREVISIBLE,empty,FALSE .endif .endif .endif .else invoke CallWindowProc,OLDSEARCH,hWnd,uMsg,wParam,lParam ret .endif invoke CallWindowProc,OLDSEARCH,hWnd,uMsg,wParam,lParam mov eax,TRUE Ret SEARCH endp...so you see at the end I added another CallWindowProc so problem was that if I don't use this call there too that the paste function isn't working anymore of this search edit control.No idea why this happens now maybe you know.As I said my code work fine and have just the problems with that WM_GETTEXT so maybe you see whats wrong or could be the problem so that I can fix this later.Thanks again. greetz
ant_man Posted August 11, 2015 Posted August 11, 2015 (edited) do you use DefWindowProc in dialog callback? Edited August 11, 2015 by ant_man
Teddy Rogers Posted August 11, 2015 Posted August 11, 2015 Possibly you need to refer to this? https://msdn.microsoft.com/en-us/library/windows/desktop/ms633570%28v=vs.85%29.aspx#designing_proc Ted.
simple Posted August 11, 2015 Posted August 11, 2015 Your problem is that the subclassed routine gets called before the message is sent, so when you SendMessage(WM_GETTEXT), the text hasn't arrived yet. This basic code should get you started, for WM_CHAR i only put in routines for upper case A & B, you will need to manually add every item on a keyboard. EditBoxSubClass proc hWin:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD local Buff [256]:BYTE local EmptyValue:DWORD local KeyPressed[20]:BYTE local hGlobal:DWORD local ClipStringPointer:DWORD mov EmptyValue, 1 .if uMsg == WM_CHAR invoke SendMessage, hWin, WM_GETTEXT, sizeof Buff, addr Buff .if eax == 0 mov EmptyValue, 0 ; if eax is 0, that means it's the first item .endif invoke crt_sprintf, addr KeyPressed, addr FormatD, wParam; FormatD db "%d", 0 .if EmptyValue != 0 .if wParam == 41h invoke crt_strcat, addr Buff, addr A ; db "A", 0 .elseif wParam == 42h invoke crt_strcat, addr Buff, addr B .endif .elseif EmptyValue == 1 ; strcat doesn't work on empty strings, use memcpy, strncpy, etc .endif invoke MessageBox, NULL, addr Buff, addr KeyPressed, MB_OK .elseif uMsg == WM_PASTE ; u will need to add a routine here to concat the clipboard string w/the result of SendMessage(WM_GETTEXT), ; this just shows whats in clipboard before it arrives to the edit box invoke OpenClipboard, 0 .if eax == 0 ; handle error here, needs to exit .endif invoke GetClipboardData, CF_TEXT mov ClipStringPointer, eax .if ClipStringPointer != 0 invoke crt_sprintf, addr Buff, addr FormatS, ClipStringPointer invoke MessageBox, NULL, addr ClipStringPointer, addr ClipStringPointer, MB_OK .endif ; some codes use this, it works w/out it ;.if hGlobal != 0 ; invoke GlobalLock, hGlobal ;.endif invoke MessageBox, NULL, addr buffer2, addr buffer2, MB_OK invoke CloseClipboard .endif invoke CallWindowProc, pOrigDlgProc, hWin, uMsg, wParam, lParam ; ur other code was modding the ret val here, that was ur problem, dont touch eax here ret EditBoxSubClass endppd - if u want some coding practice in ur freetime lcf, check out codegolf.stackexchange.com , u can do masm there, the people are friendly, the challenges are very realistic and u learn stuff like how GUI frameworks work, how to work w/strings, etc.
LCF-AT Posted August 11, 2015 Author Posted August 11, 2015 (edited) Hi again and thanks for new infos so far. So I check this and still can't get it working with WM_KEYDOWN or also WM_CHAR.WM_PASTE I got it working now so I also added a code today to check the clipboard content so this work now as it should. The other CHAR & KEYDOWN I can't handle with WM_GETTEXT so it always hangs one time behind. I checked your code simple but I don't wanna really add a check for each key item etc so thats a bad solution. I tried again a little bit and wrote some other code what also not works perfect yet but now I am no more in the mood to waste more time with that pipifax.Maybe tomorrow again or I write the code completely new so its already messed up.Here what I got now... SEARCH proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM local all:DWORD local empty:DWORD local A1:DWORD local A2:DWORD LOCAL buffas [256]:BYTE LOCAL buffas2 [256]:BYTE .if uMsg == WM_PASTE invoke RtlZeroMemory,addr SEARCHINGBUFFER, sizeof SEARCHINGBUFFER invoke IsClipboardFormatAvailable, CF_TEXT .if eax != 0h invoke OpenClipboard, NULL .if eax != 0h invoke GetClipboardData, CF_TEXT .if eax != 0h mov esi, eax invoke lstrlen,esi invoke SendMessage,hWnd,WM_SETTEXT,eax,esi invoke CloseClipboard invoke lstrlen,addr SEARCHINGBUFFER mov A1, eax mov A2, eax invoke SendMessage,hWnd,EM_SETSEL,addr A1, addr A2 jmp AB .else .endif .else .endif .else .endif .elseif uMsg == WM_CUT || uMsg == WM_CLEAR invoke RtlZeroMemory,addr SEARCHINGBUFFER, sizeof SEARCHINGBUFFER invoke SendMessage,hWnd,WM_SETTEXT,sizeof SEARCHINGBUFFER,addr SEARCHINGBUFFER .elseif uMsg == WM_CHAR push wParam pop char nop .if char == 08h ; delete sign invoke RtlZeroMemory,addr buffas, sizeof buffas invoke SendMessage,hWnd,WM_GETTEXT,sizeof buffas,addr buffas .if eax == 0h jmp WS .else mov edi, eax ; leght invoke SendMessage,hWnd,EM_GETSEL,addr A1, addr A2 cmp eax, 0h je NORMAL_ONE_DELETE xor ecx, ecx mov cx, ax shr eax, 10h cmp eax, ecx jne NAU dec ecx NAU: mov edi, offset SEARCHINGBUFFER add edi, ecx sub eax, ecx invoke RtlZeroMemory,edi, eax jmp TONS NORMAL_ONE_DELETE: mov eax, offset SEARCHINGBUFFER dec edi sub eax, edi mov esi, eax invoke RtlZeroMemory,esi, edi invoke SendMessage,hWnd,WM_SETTEXT,edi,esi .endif .endif invoke SendMessage,hWnd,EM_GETSEL,addr A1, addr A2 .if eax != 0h xor ecx, ecx mov cx, ax shr eax, 10h cmp eax, ecx jne RONS invoke SendMessage,hWnd,WM_GETTEXT,sizeof SEARCHINGBUFFER,addr SEARCHINGBUFFER jmp HONS RONS: mov edi, offset SEARCHINGBUFFER add edi, ecx sub eax, ecx invoke RtlZeroMemory,edi, eax .endif HONS: invoke lstrcat,addr SEARCHINGBUFFER,addr char TONS: invoke SendMessage,hWnd,WM_SETTEXT,sizeof SEARCHINGBUFFER,addr SEARCHINGBUFFER invoke lstrlen,addr SEARCHINGBUFFER mov A1, eax mov A2, eax invoke SendMessage,hWnd,EM_SETSEL,addr A1, addr A2 AB: invoke RtlZeroMemory,addr buffas, sizeof buffas invoke RtlZeroMemory,addr buffas2, sizeof buffas2 invoke SendMessage,hWnd,WM_GETTEXT,sizeof buffas,addr buffas .if eax != 0h mov edi, eax mov empty, 0h dec empty mov all, 0h invoke SendMessage, LISTVIEW,LVM_GETITEMCOUNT,0,0 .if eax!=0h mov all, eax SELCHECKO_1A: inc empty mov ebx, empty mov lvi6.imask,LVIF_TEXT mov lvi6.iItem,ebx mov lvi6.iSubItem,1 lea eax, buffas2 mov lvi6.pszText, eax mov lvi6.cchTextMax, sizeof buffas2 invoke SendMessage,LISTVIEW, LVM_GETITEMTEXT, ebx, addr lvi6 invoke CompareString,0,NORM_IGNORECASE,addr buffas,edi,addr buffas2,edi ;;; .if eax!=2h mov eax, empty cmp eax, all jb SELCHECKO_1A .else mov lvi6.imask,LVIF_STATE mov lvi6.state,0 mov lvi6.stateMask, LVIS_SELECTED or LVIS_FOCUSED invoke SendMessage,LISTVIEW,LVM_SETITEMSTATE,-1, addr lvi6 mov lvi6.state,LVIS_SELECTED or LVIS_FOCUSED mov lvi6.stateMask, LVIS_SELECTED or LVIS_FOCUSED invoke SendMessage,LISTVIEW,LVM_SETITEMSTATE,empty, addr lvi6 invoke SendMessage,LISTVIEW,LVM_ENSUREVISIBLE,empty,FALSE .endif .endif .endif .else WS: invoke CallWindowProc,OLDSEARCH,hWnd,uMsg,wParam,lParam ret .endif mov eax,TRUE ;invoke CallWindowProc,OLDSEARCH,hWnd,uMsg,wParam,lParam Ret SEARCH endp Thanks for the link of the site simple,will see whether I can find something there if I need something but on the other hand you still here to answer my questions (mostly). EDIT: No I don't use DefWindowProc just normal DialogBoxParam calls without any callbacks etc.Just see into the example of "WinAsm\Templates\Dialog\bones" thats how I use it too always if I do start any project.I don't use DefWindowProc / GetMessage / TranslateMessage / DispatchMessage loop.I don't like this way. Thanks also for the link Ted but anyhow isn't really working for me what is a bit strange so all of my other subclassing routines do work normaly and they I have also build like this SEARCH routine. greetz Edited August 11, 2015 by LCF-AT
simple Posted August 12, 2015 Posted August 12, 2015 (edited) yeah don't use the other way do this instead. Also u don't have to zero memory on buffer, it's already zero, & if u do I think the better way is to use memset() because Rtl is used for drivers and location could change. edit: dont use the WM_CHAR way in the last post#184 but the WM_PASTE should work DragDropProc proc hWin:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD local Buff [256]:BYTE local KeyState[256]:BYTE local EmptyValue:DWORD local KeyPressed[20]:BYTE local hGlobal:DWORD local ClipStringPointer:DWORD local VirtualKey:DWORD local ScanCode:DWORD local WcharPointer:DWORD local WcharEditBox:DWORD local FullWcharString:DWORD local Len:DWORD mov EmptyValue, 1 .if uMsg == WM_CHAR invoke SendMessage, hWin, WM_GETTEXT, sizeof Buff, addr Buff .if eax == 0 mov EmptyValue, 0 ; if eax is 0, that means it's the first item .endif movzx eax, byte ptr ss:[ebp + 16h] ; ebp + 14h = lParam, 16h = lParam[2] = scancode mov ScanCode, eax invoke MapVirtualKey, ScanCode, MAPVK_VSC_TO_VK mov VirtualKey, eax invoke GetKeyState, 0 invoke GetKeyboardState, addr KeyState ; use this for unicode. useful functions autotranslate ;invoke ToUnicode, VirtualKey, ScanCode, addr KeyState, addr WcharPointer, 4, 0 invoke ToAscii, VirtualKey, ScanCode, addr KeyState, addr WcharPointer, 0 .if eax != 0 && EmptyValue != 0 ; string must be null terminated lea eax, WcharPointer mov byte ptr [eax + 1], 0 ; for unicode do + 4 invoke crt_strcat, addr Buff, addr WcharPointer .endif invoke MessageBox, NULL, addr Buff, addr Buff, MB_OK .elseif uMsg == WM_PASTE Edited August 12, 2015 by simple
LCF-AT Posted August 12, 2015 Author Posted August 12, 2015 Hi again, thanks for you code simple but isn't working on first press too.I wrote the WM_CHAR code new today and after some time I got it working now so far also + to handle the selections if something is selected. .elseif uMsg == WM_CHAR nop nop nop push wParam pop char nop .if char == 08h ; delete sign invoke RtlZeroMemory,addr SEARCHINGBUFFER, sizeof SEARCHINGBUFFER invoke SendMessage,hWnd,WM_GETTEXT,sizeof SEARCHINGBUFFER,addr SEARCHINGBUFFER .if eax == 0h jmp WS .endif mov edi, eax ; leght invoke SendMessage,hWnd,EM_GETSEL,addr A1, addr A2 .if eax == 0h ; normal delete mov eax, offset SEARCHINGBUFFER dec edi sub eax, edi mov esi, eax invoke RtlZeroMemory,esi, edi invoke SendMessage,hWnd,WM_SETTEXT,edi,esi jmp AB .else xor ecx, ecx mov cx, ax shr eax, 10h mov edi, offset SEARCHINGBUFFER .if ecx == eax mov A1, ecx ; start dec ecx add edi, ecx sub eax, ecx mov esi, eax invoke RtlZeroMemory,edi, eax add edi, esi cmp byte ptr [edi], 00h je SANG0 invoke lstrlen,edi mov ecx, eax ; rest mov A2, ecx ; rest pushad invoke RtlZeroMemory,addr temp, sizeof temp popad mov esi, edi lea edi, temp REP MOVS BYTE PTR ES:[EDI],BYTE PTR DS:[ESI] xchg esi, edi sub esi, A2 mov edi, offset SEARCHINGBUFFER add edi, A1 dec edi mov ecx, A2 REP MOVS BYTE PTR ES:[EDI],BYTE PTR DS:[ESI] mov byte ptr [edi], 00h SANG0: invoke SendMessage,hWnd,WM_SETTEXT,sizeof SEARCHINGBUFFER,addr SEARCHINGBUFFER invoke lstrlen, offset SEARCHINGBUFFER mov A1, eax mov A2, eax invoke SendMessage,hWnd,EM_SETSEL,addr A1, addr A2 ;.elseif ecx > eax ; nop ; nop .else mov A1, ecx ; start sel mov A2, eax ; end sel add edi, ecx sub eax, ecx mov ecx, eax mov A3, ecx ; between xor eax, eax REP STOS BYTE PTR ES:[EDI] cmp byte ptr [edi], 0h je SANG1 invoke lstrlen,edi mov ecx, eax ; rest mov A2, ecx ; rest pushad invoke RtlZeroMemory,addr temp, sizeof temp popad mov esi, edi lea edi, temp REP MOVS BYTE PTR ES:[EDI],BYTE PTR DS:[ESI] xchg esi, edi sub esi, A2 mov edi, offset SEARCHINGBUFFER add edi, A1 mov ecx, A2 REP MOVS BYTE PTR ES:[EDI],BYTE PTR DS:[ESI] mov byte ptr [edi], 00h SANG1: invoke SendMessage,hWnd,WM_SETTEXT,sizeof SEARCHINGBUFFER,addr SEARCHINGBUFFER invoke lstrlen, offset SEARCHINGBUFFER mov A1, eax mov A2, eax invoke SendMessage,hWnd,EM_SETSEL,addr A1, addr A2 .endif .endif .else invoke SendMessage,hWnd,EM_GETSEL,addr A1, addr A2 .if eax != 0h xor ecx, ecx mov cx, ax shr eax, 10h mov edi, offset SEARCHINGBUFFER .if ecx == eax FANG0: invoke SendMessage,hWnd,WM_GETTEXT,sizeof SEARCHINGBUFFER,addr SEARCHINGBUFFER invoke lstrcat,addr SEARCHINGBUFFER,addr char invoke SendMessage,hWnd,WM_SETTEXT,sizeof SEARCHINGBUFFER,addr SEARCHINGBUFFER invoke lstrlen, offset SEARCHINGBUFFER mov A1, eax mov A2, eax invoke SendMessage,hWnd,EM_SETSEL,addr A1, addr A2 ; .elseif ecx > eax ; nop ; nop .else mov A1, eax ; end sel add edi, ecx lea esi, char sub eax, ecx mov ecx, eax mov A3, ecx mov ecx, 1h REP MOVS BYTE PTR ES:[EDI],BYTE PTR DS:[ESI] mov edi, offset SEARCHINGBUFFER add edi, A1 cmp byte ptr [edi],0h jne FANG1 sub edi, A3 inc edi jmp FANG2 FANG1: invoke lstrlen,edi mov ecx, eax ; rest mov A2, ecx ; rest pushad invoke RtlZeroMemory,addr temp, sizeof temp popad mov esi, edi lea edi, temp REP MOVS BYTE PTR ES:[EDI],BYTE PTR DS:[ESI] xchg esi, edi sub esi, A2 mov edi, offset SEARCHINGBUFFER add edi, A1 mov ecx, A2 REP MOVS BYTE PTR ES:[EDI],BYTE PTR DS:[ESI] FANG2: mov byte ptr [edi], 00h invoke SendMessage,hWnd,WM_SETTEXT,sizeof SEARCHINGBUFFER,addr SEARCHINGBUFFER invoke lstrlen, offset SEARCHINGBUFFER mov A1, eax mov A2, eax invoke SendMessage,hWnd,EM_SETSEL,addr A1, addr A2 .endif .else invoke lstrcat,addr SEARCHINGBUFFER,addr char invoke SendMessage,hWnd,WM_SETTEXT,sizeof SEARCHINGBUFFER,addr SEARCHINGBUFFER invoke lstrlen,addr SEARCHINGBUFFER mov A1, eax mov A2, eax invoke SendMessage,hWnd,EM_SETSEL,addr A1, addr A2 .endif .endif ;;;;;;;;;;;;;;;;;;;;;;;;;;Should work now better than before.I will check this with Rtl API.Thanks again so far and till later. greetz
simple Posted August 13, 2015 Posted August 13, 2015 code was just to get u started, to make it work on 1st press all u do is add a 3 line routine for empty value w/memcpy, it works fine. glad it works but thats a lot of code.
LCF-AT Posted August 13, 2015 Author Posted August 13, 2015 Hi again, yes I know its a lot code now just for that little checking thing. Anyway,it works now and I also added a Loop button / function what checks entire list for entered letter parts / words etc what also work well. I have another question and this time its more about some visual stuff.So I also use context menus in my app (tray too) and wanna make the look of them a little better with some icons / images before the menu strings.In the past I tried this already but at the end I always get some not very good looking results.On the net I am looking for any kind of icons (exit / restore / play etc) to use them but isn't really working (mostly I get any sizes error in WinASM) so that I have to change them to bitmaps but they look then very pixi and bad etc you know what I mean right.I use this method.... invoke AppendMenu,hPopupMenu,MF_STRING,IDM_DOWN,addr MovdownString invoke LoadImage,hInstance,566,IMAGE_BITMAP,14,14,LR_DEFAULTCOLOR invoke SetMenuItemBitmaps, hPopupMenu, IDM_DOWN, MF_BYCOMMAND, eax, eax ...so how can I do it simple with using icons and to show them also very clear (not pixi or so) and what icons do I need (only need one 16x16 icon or) and what code / APIs should I use?Do you have also any example for that?Next thing I wanna ask is how to create any good looking background of context window?Just wanna make the look a little more pro and not so in 0815 style you know.Maybe you can show me something etc would be nice again. greetz 1
simple Posted August 14, 2015 Posted August 14, 2015 U can use BitBlt to both load images in the background & set context menu images. There's a lot of code samples/solutions if u search around (& they all look like garbage) u want pro? again, gtfo of winapi! in 2015 i have never heard of a coder using winapi (or anything MS) to ship a gui product, gdi, gdi+, winapi, mfc, they're all sh!t.
Teddy Rogers Posted August 14, 2015 Posted August 14, 2015 If you are after some simple icons that come with Windows you could look at using default icons in shell32.dll and from Vista onward imageres.dll. API you could use... ExtractIconEx_("shell32.dll", IconNum, #Null, @iIcon, 1)For other icon functions... https://msdn.microsoft.com/en-us/library/windows/desktop/ff468847%28v=vs.85%29.aspx What kind of context menu are you thinking of doing, CreatePopupMenu, TrackPopupMenuEx? There are many ways for adding the background, have you any specific ideas what it is you are trying to do? Ted.
LCF-AT Posted August 14, 2015 Author Posted August 14, 2015 Hi again, good ok but I can just work with what I have now etc. Ok listen,now I tried again to play with just the icons to show them correctly and clear into popup menus but I don't get it working just with icons.I checked my old stuff and found again something I tried before already.... invoke LoadImage,hInstance,214,IMAGE_ICON,16,16,LR_DEFAULTCOLOR invoke BitmapFromIcon,hWnd,eax invoke SetMenuItemBitmaps, hPopupMenuX, IDM_RESTORE, MF_BYCOMMAND, eax, eax BitmapFromIcon is any custom routine ...problem is that the icons looking mushy & fat & just bad not as the original icon.If I increase the size of loadimage API to 17 & 17 then its a little bit better but still bad.Yesterday I did download Teddys PinMe tool and have seen its also using popmenus with icons but there are looking all icons 1A as the original icons and this I wanna also have but how?I found that exit icon into shell32.dll same as Teddy use but with the method I use above it converts the icon to bitmap etc but isn't looking so well.Do you have any short example code of the icon part maybe? EDIT: Hi Ted,yes I have seen you do use icons from shell32 (how do you know what icon number in shell used the exit icon?In my shell I can find it under number 240 / F0 hex but I don't see that the API you use does call this number.Are the number also same in each shell32 dll of all systems?) so I didn't know that this is possible and to use them for yourself.Yes I do use CreatePopupMenu functions and AppendMenu.So I just wanted to bring some color into popup menu background so I have seen something like this in other apps (delphi for example) where the first line (where Icons are) is colored + other color where text is etc.Was just idea to do similar things but I don't have a clue yet.Now I got the problems with that icons and wanna get this working as in your PinMe tool.I ripped the exit icons from shell already and added it into my resources but don't know how to draw it as you do you know.Below 2 pics of PinMe & my try. Thanks
Pancake Posted August 14, 2015 Posted August 14, 2015 Maybe small offtopic, but could you clear the inbox LCF-AT? I would like to ask you a question
LCF-AT Posted August 16, 2015 Author Posted August 16, 2015 Hi again, could anyone post a example or API functions list how to send a icon into popup menu?CreateCompatibleDC / CreateDIBSection / DrawIconEx etc.I can't find any example on internet. @ Pancake Deleted some PMs now. greetz
Teddy Rogers Posted August 16, 2015 Posted August 16, 2015 You shouldn't have to resize the icons from shell32 if you use the 16x16 icons so make sure you are using the correct icons, it may explain why they look funny to you. How do I know which one's to use? I created an icon image tool to view them. I'll post some code and upload a copy of my icon image tool with source once I am back home, most likely tomorrow (Monday) the way things are looking... Ted. 1
LCF-AT Posted August 17, 2015 Author Posted August 17, 2015 Hi Ted, sounds great if you could send some code to see what I have to do to get it working like in your PinMe tool to show all icons very clear & original.No idea why I can't find anything on internet about that (just find icon to bmp what I don't want and its looking like on my picture I did post).Anyway,so I will wait till you send something helpfully for me. Thanks in advance and till later. greetz
LCF-AT Posted August 18, 2015 Author Posted August 18, 2015 Hi its me again, short info: I got some success about my icons into popup menu.So it was little bit costly to handle that now with a MF_OWNERDRAW but I got it working now so far (yeah) to show all icons orignal & clean.Below you can see my picture in Listview. So on that way I can give my menus nice icons etc but the problem I have now is that I wanna also do it with my tray icon / right mouse click but I don't know what I have to subclass for my tray!?!Problem is that I need to catch the WM_DRAWITEM & WM_MEASUREITEM messages but they got not triggered in my main procedere only if I subclass anything but I don't know what ID handle to subclass for that.What to do in that case and what to subclass? @ Ted So you still can send me your icon code too so that I can see how you did it with your method and to lern some more. greetz
Teddy Rogers Posted August 20, 2015 Posted August 20, 2015 Apologies for the late reply, you can blame my wife for consuming my time over the last few days. Are you using a callback and how are you capturing and processing events - do you have some sample code? Regarding the icon viewer tool, I posted this in a blog entry I just made. You can find it here... https://forum.tuts4you.com/blog/27/entry-158-extracticonex-revisited/ Have you read my blog post regarding animated tray icons? Ted. 1
LCF-AT Posted August 20, 2015 Author Posted August 20, 2015 Hi Ted, thanks for your files + code.First I have to tell you that your Cycle Icons app isn't working with the imageres.dll & shell32.dll so both dll resources are much corrupted so I checked this in a Res tool.Just only a info for you.I changed the file with my shell32.dll (renamed it) and now it works to show all icons of the dll. Ok back to my icons problems.I don't use callback or capturing etc so I just wanna know how to show icons in menus (popup / right mouse) and specially in a tray menu (as your PinMe tool does) without to mod them like with the icon 2 BMP method etc.Now I got it working to show icons in menus using MF_OWNERDRAW flag for ModifyMenu API & catching WM_DRAWITEM & WM_MEASUREITEM in my menu subclass + filling the DRAWITEMSTRUCT.This method isn't very simple but its working so far as you can see on my picture on post 197 (the icons I added into my resources so I don't need to extract them).The next problem I have now is how to show icons in the tray popup menu as your PinMe tool so for that I can't subclass any control like I did before for Listview / Tabs etc you know and I don't know what to subclass for the tray or whether there is anything to subclass but without subclassing I can't get the WM_DRAWITEM & WM_MEASUREITEM messages thats the problem.I do use a tray method as in Iczelion tutorial 23...(more or less) http://win32assembly.programminghorizon.com/tut23.html ...this small app you can down to tray and you also get a popup menu with 2 entrys and right there before I wanna set icons (as your PinMe tool) but how? Would be nice if you could have a look or maybe you could post the code pb of your PinMe tool or just the part of the tray / popup menu / icons or maybe you can add a tray + popup menu + icon in your Quick Icon Viewer v0.1.pb tool so that I can see the code for that later in your pb source etc.Something like that maybe if possible. PS: Short infos Ted about FF and your Site.So in the last days I got again some offten problems to access T4Y (sec_error_ocsp_try_server_later). Only in FF of course.Now I did disabled my security.ssl.enable_ocsp_stapling option in about:config now to access T4Y again.No idea why FF has problems with your site from time to time. greetz
LCF-AT Posted August 22, 2015 Author Posted August 22, 2015 Hi again, sorry to bother you again with my questions guys so I hope you don't mind.Unfortunately I got no luck so far to find ANYTHING about how to display icons (without SetMenuItemBitmaps API) in a tray popup menu and also nothing about how to subclass the tray to receive WM_DRAWITEM & WM_MEASUREITEM.Uhhhmmmm!I can find many else stuff about Ownerdraws for menus which belong to any windows (they you can SC) but not for the tray menu so its really weird.Now I can't search anymore on internet (got no power anymore) and hope to get any new infos from any coder of T4Y. Thanks and till later
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now