flat assembler
Message board for the users of flat assembler.

Index > Windows > A question on Tooltips

Author
Thread Post new topic Reply to topic
clamicun



Joined: 04 Dec 2013
Posts: 77
Location: Muenster NRW Germany
clamicun
System WIN7 32bit.

Haleluja I made it. Took me days.
A tooltip template with 'CreatewindowEx' buttons.
Every example I found in the net was made either with a dialogbox or a bmp toolbar.
It works. Seems to be ok, BUT...

If I click on a button, this particular button does not show its tooltip anymore before the mouse hovers over another button.
Then it works again.
Seems that after a click the 'communication' between this button and the buttonproc is interupted.
How to fix this 'bug' ?

Please download the zipfile (it contains the bmps) and have a look.
Thank you.

P.S.
Microsoft says I should use
GetWindowLongPtr instead of GetWindowLong
to ensure proper 64bit compatibility.

Unfortunately this is not that easy, because GetWindowLongPtr doesn't exist in 32bit Windows.

Does my program run on a 64bit computer?

Look here.
http://www.pinvoke.net/default.aspx/user32/GetWindowLongPtr.html


Description:
Download
Filename: myTooltips.zip
Filesize: 11.28 KB
Downloaded: 60 Time(s)

Post 02 Jun 2014, 12:35
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
Don't know what tooltip you are talking about.

Image

Windows 7 Ultimate, 64-bit


clamicun wrote:
Unfortunately this is not that easy, because GetWindowLongPtr doesn't exist in 32bit Windows
Don't be lazy, a simple architecture check will overcome that obstacle.
Post 02 Jun 2014, 12:52
View user's profile Send private message Reply with quote
clamicun



Joined: 04 Dec 2013
Posts: 77
Location: Muenster NRW Germany
clamicun
Hello typedef,
did you read my P.S. ?

So it does not run on 64-bit machines.

____________________
32 Bit Windows

On this platform this function is in fact a macro that calls GetWindowLong, so the EntryPoint property has to be set to the real function:
C# Signature:

[DllImport("user32.dll", EntryPoint="GetWindowLong")]
static extern IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex);

???

This way it looks on my 32-bit machine.


Description:
Filesize: 5.54 KB
Viewed: 1407 Time(s)

my_tootips3.jpg


Description:
Filesize: 5.46 KB
Viewed: 1407 Time(s)

my_tooltips1.jpg




Last edited by clamicun on 03 Jun 2014, 11:26; edited 1 time in total
Post 02 Jun 2014, 13:49
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
clamicun wrote:
Hello typedef,
did you read my P.S. ?

So it does not run on 64-bit machines.


It seems you have a hard time reading stuff. Do you even bother to look?
clamicun wrote:

____________________
32 Bit Windows

On this platform this function is in fact a macro that calls GetWindowLong, so the EntryPoint property has to be set to the real function:
C# Signature:

[DllImport("user32.dll", EntryPoint="GetWindowLong")]
static extern IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex);

???


??? Mad Mad Mad

1st. Read documentation and Google search.
2nd. Use DLL tools to check for APIs.
3rd. You are looking at .NET code. In C/C++ it's just a macro that resolves to Get/SetWindowLongA/W

There's no such API as Get/SetWindowLongPtr. It's a MACRO for fuck's sake.
Post 02 Jun 2014, 15:43
View user's profile Send private message Reply with quote
clamicun



Joined: 04 Dec 2013
Posts: 77
Location: Muenster NRW Germany
clamicun
typedef,
Sems you have a hard time reading stuff. Do you even bother to look?
It's a MACRO for fuck's sake.
-----------

You do not talk to me this way -you dirty fucking -very likely usamerican- dumbfuck.
Have a bad afternoon!
Post 02 Jun 2014, 16:05
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
clamicun wrote:
typedef,
Sems you have a hard time reading stuff. Do you even bother to look?
It's a MACRO for fuck's sake.
-----------

You do not talk to me this way -you dirty fucking -very likely usamerican- dumbfuck.
Have a bad afternoon!

That's the spirit kid. Now, do us a favor and RTFM.
Post 02 Jun 2014, 18:03
View user's profile Send private message Reply with quote
clamicun



Joined: 04 Dec 2013
Posts: 77
Location: Muenster NRW Germany
clamicun
I am still working with creating tooltips.

It works fine, but when a button was clicked, this particular button
shows the tooltip only after the cursor hovered over another button.

Now I made the same program with MASM.
Tried to create it as equal to FASM as possible.

Why does it work properly and Fasm does not.
There must be a reason.

Here are the 2 programs as zipfiles


Description:
Download
Filename: fasm_Tooltips.zip
Filesize: 11.54 KB
Downloaded: 58 Time(s)

Description:
Download
Filename: masm_Tooltips.zip
Filesize: 11.75 KB
Downloaded: 65 Time(s)

Post 08 Jun 2014, 14:56
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1419
Location: Toronto, Canada
AsmGuru62
Can you do a simple test?
You show a dialog after clicking a button.
Try not to do that. Just comment these lines.
Then click button and then hover and check if tooltip will appear.
Post 08 Jun 2014, 17:40
View user's profile Send private message Send e-mail Reply with quote
Walter



Joined: 26 Jan 2013
Posts: 143
Walter
Sorta like AsmGuru62 said:

Code:
.open_enc:
        invoke MessageBox,0,tip_enc,tip_enc,0
        jmp .finish
.open_dec:
        invoke MessageBox,0,tip_dec,tip_dec,0
        jmp .finish
    
Post 08 Jun 2014, 18:27
View user's profile Send private message Reply with quote
clamicun



Joined: 04 Dec 2013
Posts: 77
Location: Muenster NRW Germany
clamicun
AsmGuru62 wrote:
Can you do a simple test?
You show a dialog after clicking a button.
Try not to do that. Just comment these lines.
Then click button and then hover and check if tooltip will appear.

;--------

Yes AsmGuru62

.open_enc:
;invoke MessageBox,[HWND],tip_enc,tip_enc,0
jmp .finish

If the MessageBox does not show up (the click goes directly back to .finish),
the tooltips keep working.
So it has to do with the messagebox ?
;-------
Yes, if I set the owner of the messagebox NULL, it works.


That is why the MASM version works.

;-----
Post 09 Jun 2014, 15:46
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1419
Location: Toronto, Canada
AsmGuru62
I think it has something to do with the loss of focus or loss of activation... and
opening a dialog (message box is a dialog) makes that change.
That is strange, however.
I think software should work whatever other window is opening or not.
Post 09 Jun 2014, 17:18
View user's profile Send private message Send e-mail Reply with quote
clamicun



Joined: 04 Dec 2013
Posts: 77
Location: Muenster NRW Germany
clamicun
AsmGuru62 wrote:
I think it has something to do with the loss of focus or loss of activation... and
opening a dialog (message box is a dialog) makes that change.
That is strange, however.
I think software should work whatever other window is opening or not.


--------------------
Good evening (22.46 h) AsmGuru62 ,

Whatever it has to do with ...

I too think that it is very strange.

Let "future generations" resolve this .

Thank you very much for all your "tips" !
Post 11 Jun 2014, 20:47
View user's profile Send private message Reply with quote
Walter



Joined: 26 Jan 2013
Posts: 143
Walter
Code:
;fasm 32 programme
format PE GUI 4.0
entry start

include 'win32a.inc'        ;You might have to modify this path
include 'include\ENCODING\utf8.inc'

section '.text' code readable executable

start:
        invoke  GetModuleHandle,NULL
        mov     [wc.hInstance],eax
        invoke  LoadCursor,NULL,IDC_ARROW
        mov     [wc.hCursor],eax
        invoke CreateSolidBrush,333333h
        mov [wc.hbrBackground],eax             ;Backgroundcolor Window
        invoke  RegisterClass,wc
        invoke  InitCommonControlsEx,icex
        invoke  CreateWindowEx,WS_EX_CLIENTEDGE,class_wnd,class_Tooltips,WS_VISIBLE+WS_BORDER,\
                                            350,300,300,200,NULL,NULL,[wc.hInstance],NULL
        mov [main_wnd],eax
        invoke ShowWindow,[main_wnd],SW_SHOWNORMAL
        invoke UpdateWindow,[main_wnd]
msg_loop:
        invoke  GetMessage,msg,NULL,NULL,NULL
        cmp     eax,1
        jb      end_loop
        jne     msg_loop
        invoke  TranslateMessage,msg
        invoke  DispatchMessage,msg
        jmp     msg_loop
end_loop:
        invoke  ExitProcess,0
;---------------------------------------
proc WindowProc HWND,wmsg,wparam,lparam
        push    ebx esi edi
        cmp     [wmsg],WM_CREATE
        je      .wmcreate
        cmp     [wmsg],WM_COMMAND
        je      .wmcommand
.defwndproc:
        invoke  DefWindowProc,[HWND],[wmsg],[wparam],[lparam]
        jmp     .finish
.wmcreate:
            invoke  CreateWindowEx,NULL,class_button,NULL,WS_CHILD+WS_VISIBLE+BS_PUSHBUTTON+BS_BITMAP,0,\
                                                       0,40,40,[HWND],IDM_ENC,[wc.hInstance],NULL
             mov [btn_hnd1],eax

             invoke  LoadBitmap,[wc.hInstance],70      ;IDM enc
             mov     [bmp_hnd1],eax
             invoke  SendMessage,[btn_hnd1],BM_SETIMAGE,IMAGE_BITMAP,[bmp_hnd1]

             invoke CreateWindowEx,NULL,class_Tooltips,NULL,TTS_ALWAYSTIP+TTS_BALLOON,\
                        CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,[btn_hnd1],NULL,[wc.hInstance],NULL
             mov [tt_hnd_enc],eax

             mov [ti.cbSize],sizeof.TOOLINFO
             mov [ti.uFlags],TTF_IDISHWND+TTF_SUBCLASS
             mov eax,[btn_hnd1]
             mov [ti.hwnd],eax
             mov [ti.uId],eax
             mov [ti.lpszText],LPSTR_TEXTCALLBACK
             invoke SendMessage,[tt_hnd_enc],TTM_ADDTOOL,0,ti

             invoke SetWindowLong,[btn_hnd1],GWL_WNDPROC,ButtonProc
             invoke SetWindowLong,[btn_hnd1],GWL_USERDATA,eax
;-----
             invoke  CreateWindowEx,NULL,class_button,NULL,WS_CHILD+WS_VISIBLE+BS_PUSHBUTTON+BS_BITMAP,41,\0,40,40,\
                                                                        [HWND],IDM_DEC,[wc.hInstance],NULL
             mov [btn_hnd2],eax
             invoke  LoadBitmap,[wc.hInstance],71      ;IDM dec
             mov     [bmp_hnd2],eax
             invoke  SendMessage,[btn_hnd2],BM_SETIMAGE,IMAGE_BITMAP,[bmp_hnd2]

             invoke CreateWindowEx,NULL,class_Tooltips,NULL,TTS_ALWAYSTIP+TTS_BALLOON,\
                        CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,[btn_hnd2],NULL,[wc.hInstance],NULL
             mov [tt_hnd_dec],eax

             mov [ti.cbSize],sizeof.TOOLINFO
             mov [ti.uFlags],TTF_IDISHWND+TTF_SUBCLASS
             mov eax,[btn_hnd2]
             mov [ti.hwnd],eax
             mov [ti.uId],eax
             mov [ti.lpszText],LPSTR_TEXTCALLBACK
             invoke SendMessage,[tt_hnd_dec],TTM_ADDTOOL,0,ti

             invoke SetWindowLong,[btn_hnd2],GWL_WNDPROC,ButtonProc
             invoke SetWindowLong,[btn_hnd2],GWL_USERDATA,eax
;-----
             invoke  CreateWindowEx,NULL,class_button,NULL,WS_CHILD+WS_VISIBLE+BS_PUSHBUTTON+BS_BITMAP,250,\0,40,40,\
                                                                        [HWND],IDM_EXIT,[wc.hInstance],NULL
             mov [btn_hnd3],eax
             invoke  LoadBitmap,[wc.hInstance],72      ;IDM exit
             mov     [bmp_hnd3],eax
             invoke  SendMessage,[btn_hnd3],BM_SETIMAGE,IMAGE_BITMAP,[bmp_hnd3]

             invoke CreateWindowEx,NULL,class_Tooltips,NULL,TTS_ALWAYSTIP+TTS_BALLOON,\
                        CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,[btn_hnd3],NULL,[wc.hInstance],NULL
             mov [tt_hnd_exit],eax

             mov [ti.cbSize],sizeof.TOOLINFO
             mov [ti.uFlags],TTF_IDISHWND+TTF_SUBCLASS
             mov eax,[btn_hnd3]
             mov [ti.hwnd],eax
             mov [ti.uId],eax
             mov [ti.lpszText],LPSTR_TEXTCALLBACK
             invoke SendMessage,[tt_hnd_exit],TTM_ADDTOOL,0,ti

             invoke SetWindowLong,[btn_hnd3],GWL_WNDPROC,ButtonProc
             invoke SetWindowLong,[btn_hnd3],GWL_USERDATA,eax

             jmp .finish
.wmcommand:
        mov     eax,[wparam]
        and     eax,0FFFFh
        cmp     eax,IDM_ENC
        je      .open_enc
        cmp     eax,IDM_DEC
        je      .open_dec
        cmp     eax,IDM_EXIT
        je      .wmdestroy
        jmp     .defwndproc
.wmdestroy:
        invoke MessageBox,[HWND],tip_exit,tip_exit,MB_YESNO
        cmp eax,IDNO
        je .finish
        invoke ExitProcess,NULL
 .finish:
        pop     edi esi ebx
        ret
.open_enc:
        invoke MessageBox,[HWND],tip_enc,tip_enc,0
        jmp .finish
.open_dec:
        invoke MessageBox,[HWND],tip_dec,tip_dec,0
        jmp .finish
endp

proc ButtonProc,hWnd,uMsg,wparam,lparam
         push  ebx esi edi
         mov ebx,[hWnd]

         cmp [uMsg],WM_NOTIFY
         jne out_proc

         mov ecx,[lparam]
         mov eax,[ecx+NMHDR.code]

         cmp eax,TTN_NEEDTEXT
         jne out_proc

cmp ebx,[btn_hnd1]
je btn1

cmp ebx,[btn_hnd2]
je btn2

cmp ebx,[btn_hnd3]
je btn3

jmp out_proc

;-----
         btn1:
         mov eax,tip_enc
         mov [ecx+TOOLTIPTEXT.lpszText],eax
         jmp out_proc
;-----
         btn2:
         mov eax,tip_dec
         mov [ecx+TOOLTIPTEXT.lpszText],eax
         jmp out_proc
;-----
         btn3:
         mov eax,tip_exit
         mov [ecx+TOOLTIPTEXT.lpszText],eax
         ;jmp out_proc
;-----
         out_proc:

         invoke GetWindowLong,ebx,GWL_USERDATA
         invoke CallWindowProc,eax,ebx,[uMsg],[wparam],[lparam]
         pop  edi esi ebx
         ret
endp

;--------------------------------------
section '.data' data readable writeable

main_wnd      dd ?,0
hbrBackground dd ? ,0

bmp_hnd1    dd ?,0
bmp_hnd2    dd ?,0
bmp_hnd3    dd ?,0

btn_hnd1    dd ?,0
btn_hnd2    dd ?,0
btn_hnd3    dd ?,0

tt_hnd_enc  dd ?,0
tt_hnd_dec  dd ?,0
tt_hnd_exit dd ?,0

IDM_ENC  =   98
IDM_DEC  =   99
IDM_EXIT =  100

TTS_BALLOON  = $40    ;??
;TTS_BALLOON  = 40    ;Note the difference

wc  WNDCLASS   NULL,WindowProc,NULL,NULL,NULL,NULL,NULL,hbrBackground,NULL,class_wnd

ti TOOLINFO
msg MSG

class_wnd       db 'DE_CRYPT',0
class_button    db 'BUTTON',0
class_Tooltips  db "Tooltips_class32",0

tip_enc         db 'ENCRYPT',0
tip_dec         db 'DECRYPT',0
tip_exit        db 'EXIT',0

;InitCommonontrolsEx
ICC_STANDARD_CLASSES = 00004000h
icex   INITCOMMONCONTROLSEX    sizeof.INITCOMMONCONTROLSEX,ICC_STANDARD_CLASSES + ICC_TAB_CLASSES

;--------------------------------------

section '.idata' import data readable writeable

  library kernel,'KERNEL32.DLL',\
          user,'USER32.DLL',\
          comctl32,'COMCTL32.DLL',\
          gdi32,'GDI32.DLL'

  import kernel,\
         GetModuleHandle,'GetModuleHandleA',\
         ExitProcess,'ExitProcess'

  import user,\
         MessageBox,'MessageBoxA',\
         RegisterClass,'RegisterClassA',\
         CreateWindowEx,'CreateWindowExA',\
         DefWindowProc,'DefWindowProcA',\
         GetMessage,'GetMessageA',\
         TranslateMessage,'TranslateMessage',\
         DispatchMessage,'DispatchMessageA',\
         LoadCursor,'LoadCursorA',\
         LoadBitmap,'LoadBitmapA',\
         SendMessage,'SendMessageA',\
         SetWindowLong,'SetWindowLongA',\
         GetWindowLong,'GetWindowLongA',\
         CallWindowProc,'CallWindowProcA',\
         ShowWindow,'ShowWindow',\
         UpdateWindow,'UpdateWindow'

  import gdi32,\
         CreateSolidBrush,'CreateSolidBrush'

  import comctl32,\
         InitCommonControlsEx,'InitCommonControlsEx'

;--------------------------------------
section '.rsrc' resource data readable

  directory RT_BITMAP,bitmaps, \
  24,manifest

;--------------------------------------
  resource bitmaps,\
           70,LANG_ENGLISH+SUBLANG_DEFAULT,bmp1,\
           71,LANG_ENGLISH+SUBLANG_DEFAULT,bmp2,\
           72,LANG_ENGLISH+SUBLANG_DEFAULT,bmp3

           bitmap bmp1,'fasm_images\enc.bmp'
           bitmap bmp2,'fasm_images\dec.bmp'
           bitmap bmp3,'fasm_images\exit.bmp'

  resource manifest, \
           1,LANG_NEUTRAL,manifestData

  resdata manifestData
    db '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',13,10
    db '<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">',13,10
    db '<assemblyIdentity',13,10
    db ' version="1.0.0.0"',13,10
    db ' processorArchitecture="X86"',13,10
    db ' name=" "',13,10
    db ' type="win32"',13,10
    db '/>',13,10
    db '<description> </description>',13,10
    db '<dependency>',13,10
    db ' <dependentAssembly>',13,10
    db '  <assemblyIdentity',13,10
    db '   type="win32"',13,10
    db '   name="Microsoft.Windows.Common-Controls"',13,10
    db '   version="6.0.0.0"',13,10
    db '   processorArchitecture="X86"',13,10
    db '   publicKeyToken="6595b64144ccf1df"',13,10
    db '   language="*"',13,10
    db '  />',13,10
    db ' </dependentAssembly>',13,10
    db '</dependency>',13,10
    db '</assembly>',13,10
endres
    
Post 12 Jun 2014, 04:14
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1419
Location: Toronto, Canada
AsmGuru62
If I have some time I will post some code how tooltips can be made without any controls - all custom code.
I did it for my FASM Writer long ago (MFC code).
Post 12 Jun 2014, 16:04
View user's profile Send private message Send e-mail Reply with quote
clamicun



Joined: 04 Dec 2013
Posts: 77
Location: Muenster NRW Germany
clamicun
Walter,
yes ! - that way it works 100%.
I see that you changed the name of the window proc to HWND.
That is obviously better but does not cause the difference.

The difference is caused by including the manifest resource ! ?

"
resource manifest, \
1,LANG_NEUTRAL,manifestData
.
.
.
"

I haven't got a clue why and how but it does it.

Thank you very much!
Post 13 Jun 2014, 10:16
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.