News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Caps lock on Warnning while in edit box

Started by hfheatherfox07, April 18, 2011, 05:53:30 PM

Previous topic - Next topic

qWord

hi,
I've played a bit with tooltip's (attachment) - currently the Tooltip only appears while the mouse is over the edit control (the EDIT must have the focus). Also it will not work correct when caps lock is on while program start - you need to press CAPS twice times to show the warning.
Maybe somebody will get it work proper...
FPU in a trice: SmplMath
It's that simple!

hfheatherfox07

Quote from: qWord on April 19, 2011, 08:00:43 PM
hi,
I've played a bit with tooltip's (attachment) - currently the Tooltip only appears while the mouse is over the edit control (the EDIT must have the focus). Also it will not work correct when caps lock is on while program start - you need to press CAPS twice times to show the warning.
Maybe somebody will get it work proper...


Sorry it does not work at all for me


dedndave

i am trying to waddle through the if.else.endif stuff - lol (not my cup of tea)
at the same time, trying to figure out how a dialog box works

in the mean time....
it looks like you want to use GetKeyState instead of GetAsyncKeyState
bit 0 of the result tells you the caps state

hfheatherfox07

Quote from: dedndave on April 19, 2011, 08:40:25 PM
i am trying to waddle through the if.else.endif stuff - lol (not my cup of tea)
at the same time, trying to figure out how a dialog box works

in the mean time....
it looks like you want to use GetKeyState instead of GetAsyncKeyState
bit 0 of the result tells you the caps state

Actully I need to use both .... but for now I want to get one working

The idea is that If I click into that edit box and my caps are on it will invoke that message
and if I am in that edit box and I turn my caps lock on then  it will invoke that message

I have seen this done in a VB example (no source)

hfheatherfox07

@ qWord

Re: your post here :

http://www.masm32.com/board/index.php?PHPSESSID=faf058b6f7a48b76b16d2cdf2af10712&topic=12464.0

can you fix this so when i am over the static with the cursor I can do some thing like change color???


jj2007

Here is one option:

CASE WM_NOTIFY
mov edx, lParam ; Pointer to NOTIFY structure
mov eax, [edx.NMHDR.code]
.if eax==TTN_SHOW
mov ebx, [edx.NMHDR.hwndFrom] ; tooltip window handle
mov edx, [edx.NMHDR.idFrom]
.if edx==hEdit
invoke GetKeyState, VK_SHIFT
.if sword ptr ax>=0
invoke MoveWindow, ebx, -999, -999, 100, 100, 0
.endif
pop esi
or eax, -1
jmp Bye
.endif
.endif


Attached a working example. Press Shift and move the mouse into the edit field.

dedndave

maybe i am wrong, here
not being experienced with dialogs   :bg

it does not appear that the main dialog window is receiving any WM_KEYDOWN messages
i suspect that is because they are going to the edit box that has focus, instead

my first approach would be to subclass the edit controls so that you could intercept their messages
that way, you could know which has focus, and receive WM_KEYDOWN messages

i am sure there is a better way to do it
Bill (or any number of other members) could slap this out in a heart beat   :P

hfheatherfox07

@jj2007  Do you have a source for that example??? I need one for an edit box ...edit boxes are different than buttons ... how do I know if that is a button or a static with Notify ( I have made those before )

I am so lost

dedndave

ok, now i get it (thanks again to Jochen)

handle WM_NOTIFY
get the edit box handle and/or code from the NMHDR structure
then, you can look for NM_SETFOCUS or NM_KEYDOWN (examining the GetKeyState,VK_CAPITAL value)

i am a little lost in dialog boxes, not knowing what to return
and, i feel naked with no DefWindowProc   :bg

hfheatherfox07

I d have to see a working example , right now I spent so much time on this my head is spining

dedndave

i may play with it after my nap
i have no "tasks" to perform this afternoon - lol
i wanted to get my feet wet with dialog boxes, anyways

jj2007

Quote from: hfheatherfox07 on April 19, 2011, 09:10:24 PM
I d have to see a working example , right now I spent so much time on this my head is spining

I did attach a working example above, except that Shift instead of CapsLock is used (the reason being that my CapsLock button is disabled :bg)

> Do you have a source for that example???

\masm32\RichMasm\Res\SkelWinMB.asc - part of the MasmBasic library. Open in RichMasm, add the WM_NOTIFY handler shown above, press F6. Or look at the attachment (but you still need the MB library).

dedndave

i will give a quickie explanation for you (from a n00b, mind you)

when the dialog main window receives a WM_NOTIFY message...
grab wParam - it is the address of a NMHDR structure
in the NMHDR structure, you can get the handle of the edit box that sent the notification
       mov     edx,wParam
       mov     ecx,[edx].NMHDR.hwndFrom

or, better yet, the ID
       mov     ecx,[edx].NMHDR.idFrom
seeing as you have assigned the ID numbers, you can use that to tell which control sent the WM_NOTIFY

you can also get the code
       mov     eax,[edx].NMHDR.code

now, you know which edit box sent which notification

codes we may be interested in are NM_SETFOCUS and NM_KEYDOWN
and, you will want to use
       INVOKE  GetKeyState,VK_CAPITAL
       and     eax,1

to get the caps lock toggle state
you may want to add one of those in the init code to initialize a capslock state var

here are the msdn links...
http://msdn.microsoft.com/en-us/library/bb775583%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/bb775514%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/bb775497%28v=vs.85%29.aspx#notifications

that last one has all the NM_ code values near the bottom

jj2007

Actually, the tooltip's ID is identical to the control's handle. It is not logical, it's Microsoft :bg

.if eax==TTN_SHOW
  mov ebx, [edx.NMHDR.hwndFrom] ; tooltip window handle
  mov edx, [edx.NMHDR.idFrom]
  .if edx==hEdit

dedndave

sounds easy enough
i am off for a nap
i bet JJ has it up and running before i get up   :P
if not, i will take a crack at it