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

hfheatherfox07

see u all in a few days ...will be gone tomorrow

dedndave

let me start by saying, it isn't nearly as simple as it first appeared - lol
Edit Controls do not send notifications to the parent window via WM_NOTIFY
instead, they use WM_COMMAND
the documentation is a little confusing

from the Edit Control docs...
Quote
wParam = control identifier
lParam low word = control handle
lParam high word = notification code

from the WM_COMMAND docs...
QuotewParam low word = control identifier
wParam high word = notification code
lParam = control handle

i think the WM_COMMAND doc is correct and the Edit Control doc is incorrect
at least, that's how it appears by looking at the doc for EN_SETFOCUS

the notifications sent by an Edit Control to the parent are:
EN_CHANGE    300h
EN_ERRSPACE  500h
EN_HSCROLL   601h
EN_KILLFOCUS 200h
EN_MAXTEXT   501h
EN_SETFOCUS  100h
EN_UPDATE    400h
EN_VSCROLL   601h


so - focus is there, but no KEYDOWN
it looks like sub-class or super-class to get the caps lock state that way
a timer would probably be easier, but doesn't seem like a very clean way to do it
i might try using a keyboard hook, as Michael suggested to me in another thread
http://www.masm32.com/board/index.php?topic=16427.msg136108#msg136108

qWord

hi,
I've end up in creating an owner drawn control - full working example (OllyDbg-tested :bg) attached.

qWord
FPU in a trice: SmplMath
It's that simple!

dedndave

looks good   :U

i have a working hook, at least
have to go take care of dad for a while   :P

hook code...
KeyboardProc PROC nCode:SDWORD,wParam:WPARAM,lParam:LPARAM

        test    nCode,80000000h
        jz      kproc0

        INVOKE  CallNextHookEx,hhk,nCode,wParam,lParam
        ret

kproc0: mov     eax,VK_CAPITAL
        cmp     eax,wParam
        jnz     kproc1

        test    lParam,40000000h
        jnz     kproc1

        INVOKE  GetKeyState,eax
        and     eax,1
        xchg    eax,CapsState

kproc1: ret

KeyboardProc ENDP

init code...
        INVOKE  GetCurrentThreadId
        INVOKE  SetWindowsHookEx,WH_KEYBOARD,KeyboardProc,NULL,eax
        mov     hhk,eax

exit code...
        INVOKE  UnhookWindowsHookEx,hhk
thanks to MichaelW for example code   :U
i have to add a SendMessage or something to the hook code to notify the DlgProc

dedndave

#49
here's what i have so far
everything seems to be working correctly
i just need to replace the message boxes with tooltips
maybe i will get a chance to do it later today
this morning, i am installing a new garage door opener for mom   :P

updated the attachment with a smaller icon file

dedndave

the icon file could be improved upon   :P
41 Kb icon file - 4 Kb code/data/rsrc/PE

146 x 68 24-bit ???????   :eek



the attachment is the above PNG image renamed as ZIP

dedndave

i removed the 146x68 icon image and updated the attachment above (CapsLock2)
the 146x68 24-bit image for the masm32 sdk icon is used for the installer, i believe   :P

dedndave

#52
ok - here is one with tooltips

i tried to add a manifest file, but the app either crashes with a config error or does not display tooltips   :P
i have had a similar problem before, but do not recall what the solution was
i tried 3 different sizes for TOOLINFO struct, so that's not it
it's not msvcrt - i can remove that altogether, as i use no crt functions, nor mas32 lib

anyways, here it is with the manifest commented out in the resource file

this is my first whack at tooltips
if you ask me, they aren't very flexible
but then, maybe that's my fault because this is my first whack at tooltips   :lol

dedndave

maybe we can get one of the manifest geniuses to look at this one ( hint, hint, Edgar   :bg )
it would be really nice to know what causes this, too:

.... or, it may not   :P

sinsi

I get the tooltop (with or without the manifest) but only if I mouse over the edit with focus.
Light travels faster than sound, that's why some people seem bright until you hear them.

dedndave

yes - i wrote it that way   :bg
under XP MCE2005, sp3, i get no tooltips if i add the manifest
i have a slightly different manifest file that causes the above error
i also tried WS_EX_TOPMOST when creating the tooltips

the way it's written, the edit control that has focus - and, of course, caps lock must be on
you may also notice slightly different messages in the two controls
if i were to use this in an app, i'd probably only have the tooltip in the bottom edit control
user ID entry would be visible and password entry would be obfuscated with "*"

sinsi

Sorry to you and qWord but they are ugly tooltips  :lol
Light travels faster than sound, that's why some people seem bright until you hear them.

dedndave

do you have an example of pretty ones ?   :bg
i'd like to know how they change the font, too
in the windows user login password box, the "Caps Lock is On" text is bold

anyways, it was a learning experience
i needed a break from my other project, and i had been wanting to play with dialogs a little
i got my feet wet   :U

FORTRANS

Hi,

   qWord, yours looks good and works well.  Dave, your capslock2
works well except to clear the message you need the mouse,
the enter key does not work.  Your capslock3 seems very erratic
and does not work well.

Regards,

Steve N.

P.S.  Had the caps lock on when I started this, and was not warned.
;-)

dedndave

YOU'RE RIGHT, sTEVE   :lol

in fact, none of the keys work
i must have a problem with my hook   :(

ok - now i get everything except enter

ok - that's the way the original poster made the edit controls
i guess, when they hit enter in the first box, it sends them to the second
when they hit enter in the second box, i will close the dialog
have to add the code for that later

the fix for the keyboard hook is to always exit via the call to CallNextHookEx

well - normally, to see whether an edit box has pressed enter, i would have to go through
a bunch of code, sorting out structure data, etc
but, seeing as how i...
1) have a keyboard hook in place
2) keep track of the focus, anyways
i could just let the hook send a message to the dialog proc and act according to the focus   :bg

but, probably "cleaner" if i do it the right way - lol