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

Hi I am trying to create the "Caps lock is on" Warning while in edit box

The same one that you get when you log in and your caps Lock are on:

I imagine it is like invoking "Shell about"... but I can not find any thing on 
How to invoke it??

I was successful in recreating it by taking a snap shot of the screen and then converting it in to a region...but that is not the right way to do it... see "CAPSLOCK_ON Message_2.zip" inside "CapsLock Project.zip"

I am looking for three things to happen when the cursor is in ONE of the edit boxes:

1. If I press Caps lock on while in the edit box, turn on and off! The "caps lock Caps lock is on" Warning
2. If the caps Lock are on before I click into the edit box than the warning should come on.
3. How to invoke that message

I have included in the "CapsLock Project.zip" "CapsLock State.zip" which deals with
Determining if the caps lock key was pressed by using:

Invoke GetKeyState,VK_CAPITAL

And I have also tackled whether the caps are on by using:

INVOKE GetKeyState,VK_CAPITAL

see "Edit Box With CAPS ON  Warnning.zip" inside "CapsLock Project.zip"

Although I can not get the warning to come on only when I am in the edit box...
I dunno why?


I apologize in advance for the mess in the .asm of the edit box with all my notes ...but it is a work  in progress

Thank you...

jj2007


qWord

hi,
here an edit that change its background color, if CAPS LOCK is toggeld on.
Quoteinclude masm32rt.inc

WndProc proto hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

IDT_CHECK_CAPSLOCK EQU 100

.data?
    hInstance   HINSTANCE   ?
    pOrgProc   PVOID      ?
    capslock   DWORD      ?
.code
main proc
LOCAL msg:MSG

    mov hInstance,rv(GetModuleHandle,0)
   
    ; our main-window
    mov edi,rv(CreateWindowEx,0,"MDICLIENT",0,WS_VISIBLE or WS_SYSMENU,100,100,100,50,0,0,hInstance,0)
     mov pOrgProc,rv(SetWindowLong,edi,GWL_WNDPROC,WndProc)
     
    ; edit control
    mov esi,rv(CreateWindowEx,0,"EDIT",0,WS_VISIBLE or WS_CHILD,0,0,100,50,edi,0,hInstance,0)
   
    ; create timer
    invoke SetTimer,edi,IDT_CHECK_CAPSLOCK,25,0
   
    .while 1
        invoke GetMessage,ADDR msg,0,0,0
        .break .if !eax || eax == -1
        invoke TranslateMessage,ADDR msg
        invoke DispatchMessage,ADDR msg      
    .endw
   
    exit
   
main endp

WndProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
   
    .if uMsg == WM_CLOSE
        invoke PostQuitMessage,0
    .elseif uMsg == WM_CTLCOLOREDIT
        .if capslock
            invoke SetBkColor,wParam,07171FFh
            invoke CreateSolidBrush,07171FFh
        .else
            invoke SetBkColor,wParam,0ffffffh
            invoke CreateSolidBrush,0ffffffh
        .endif
        ret
    .elseif uMsg == WM_TIMER
        .if wParam == IDT_CHECK_CAPSLOCK
            mov edx,rv(GetKeyState,VK_CAPITAL)
            .if  edx & 1 && !capslock
                mov capslock,1
                invoke InvalidateRect,hWnd,0,TRUE
            .elseif !(edx & 1) && capslock
                mov capslock,0
                invoke InvalidateRect,hWnd,0,TRUE
            .endif
        .else   
@@:         jmp @F
        .endif
    .else
@@:      invoke CallWindowProc,pOrgProc,hWnd,uMsg,wParam,lParam
        ret
    .endif
    xor eax,eax
    ret
   
WndProc endp
end main
FPU in a trice: SmplMath
It's that simple!

hfheatherfox07

Thanks for the fast reply....

@ qWord

That asm keeps crashing ? I can not assemble it?

I am going to try to assemble a version with a rsrc.rc

How to translate:

    ; create timer
    invoke SetTimer,edi,IDT_CHECK_CAPSLOCK,25,0
   
    .while 1
        invoke GetMessage,ADDR msg,0,0,0

to work with "hedit1"

Thanks.....

qWord

Quote from: hfheatherfox07 on April 18, 2011, 09:38:47 PMThat asm keeps crashing ? I can not assemble it?
what erros does masm throw?
FPU in a trice: SmplMath
It's that simple!

hfheatherfox07

What I meant was that I can not assemble a successful .exe out of it the it assembles fine from the sense that it compiles , but it crashes...

Please see the 2 screen shots that I took ...one I assemble it with a BAT file ...same thing ( at the end of the bat I tried asm.exe to run it from the bat)

qWord

hi,
Currently i can't see the problem - have you test the program I've attached in my previous post?
FPU in a trice: SmplMath
It's that simple!

dedndave

it crashes here, as well - access violation
something to do with the first CreateWindowEx
it says in the docs, that if you use WS_SYSMENU, you should also specify WS_CAPTION
however, that does not fix it   :P
the other parms look ok, so far as i can tell

i am running XP sp3

hfheatherfox07

Quote from: qWord on April 18, 2011, 10:23:51 PM
hi,
Currently i can't see the problem - have you test the program I've attached in my previous post?

yes I have and  I get the same results ???

I never had this problem before ... I will try It again on a different computer tonight....
this is strange....

Do you have a version with a resource ?

I am trying to achieve this :


qWord

mhh, ok
her on Win7-x64 it works fine. Eventually the subclassing is the problem - new version attached.
FPU in a trice: SmplMath
It's that simple!

dedndave

still a crash   :bg

i put a message box after CreateWindowEx to show the handle
it never gets that far

qWord

sry - I've upload the same file again - pleas redownload from previous post  :bg

EDIT: hfheatherfox07 look here: About Tooltip Controls
FPU in a trice: SmplMath
It's that simple!

dedndave

i put a message box after CreateWindowEx to show the handle
it never gets that far
so, it's not subclassing

dedndave

i tried adding....
        push    ICC_WIN95_CLASSES
        push    sizeof INITCOMMONCONTROLSEX
        INVOKE  InitCommonControlsEx,esp
        pop     ecx
        pop     edx

no luck
maybe it needs a manifest

qWord

ok
the MDICLIENT-class requires  an pointer to the CLIENTCREATESTRUCT through lpParam.
sry for confusing you people.
[By Creating an normal window, it should work (the WndProc must also adjusted)]
FPU in a trice: SmplMath
It's that simple!