News:

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

Child Window Makes Parent Inactive - Another try

Started by raleeper, August 10, 2011, 05:41:45 AM

Previous topic - Next topic

raleeper

Well, I have my child window up and accepting (and processing) keyboard input.  It Beeps on any key it doesn't recognize (not yet set up).  It recognizes 3 keys: escape - on which it properly exits via DestroyWindow - "back" (VK_BACK), which is supposed to leave the child existing, but return focus to the parent, and keypad 1, which just beeps.

On "back" keyboard appears to return to the parent (the titlebars change color and the parent accepts keyboard input), but it does not display anything. The child remains displayed on top of what the parent last displayed.  I have not been able to find a way of reactivating the parent's display capability.

The parent's display routine (dspl) is never reached, which presumably means WM_PAINT messages are not being received.

Things I tried: (in the parent's message handler)
   cmp eax, WM_SETFOCUS
  jnz @F
test BY [flgs+2],4 ;Child Window Exist
  jz @F

invoke SetActiveWindow, hwnd
invoke UpdateWindow, hwnd
invoke SetForegroundWindow, hwnd
invoke ShowWindow, hwnd,SW_SHOW ;one at a time

  jmp WP_def


I would appreciate any suggestions.

Thanks, ral

The relevant code is:
(Note: some comments have been removed and others added to improve understandability; all numbers are hex)

WProc proc wp_hWnd,uMsg,wParam,lParam ;main windows procedure

pushad

mov eax, [wp_hWnd]
mov [hWnd], eax

mov eax, [uMsg]
mov edx, [wParam]
mov ecx, [lParam]

cmp eax, WM_DESTROY
  jz WP_des
cmp eax, WM_PAINT
  jz WP_pai
cmp eax, WM_KEYDOWN
  jz key ;calls routines based on keyboard input
;returns to WP_inv or WP_end
cmp eax, WM_SYSKEYDOWN
  jz key_s ;same

cmp eax, WM_LBUTTONDOWN ;201
  jz mseb
cmp eax, WM_LBUTTONUP ;202
  jz mseu
cmp eax, WM_MOUSEMOVE ;200
  jz mmov

WP_def:
popad
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret

WP_inv:
invoke InvalidateRect,hWnd,0,0

WP_end::
popad
xor eax,eax
ret

WP_des:
invoke PostQuitMessage,NULL
  jmp WP_end

WP_pai:
call dspl ;shows screen
test BY [flge+3],20 ;dont exit if bit 1d of
  jnz eren ;  dword flag e is set

  jmp WP_end


;;   NEWWIN   NEW child WINdow

newwin:
test BY [flgs+2],8 ;Is class registered?
  jnz newwin_0

mov ebx, OFFSET LFwcc

invoke CreateSolidBrush,0EEEE00
mov [ebx+20], eax

mov eax, [hicon]
mov [ebx+18], eax
mov [ebx+2C], eax
mov eax, [hcurs]
mov [ebx+1C], eax ;Reuse main window's icons and cursor

invoke RegisterClassEx, OFFSET LFwcc
or eax, eax
  jz germs ;Get,Format, and show Last Error

or BY [flgs+2],8 ;Class is registered

newwin_0:
mov edx, CW_USEDEFAULT
mov ecx, [hwnd] ;Handle to parent (main) window
xor eax,eax

mov esi, OFFSET ChldClass
mov edi, OFFSET ChildW

invoke CreateWindowEx,eax,esi,edi,chstyle,edx,edx,edx,edx,\
ecx,0,hinst,eax

mov [hcwnd], eax
or eax, eax
  jz germs

invoke ShowWindow,hcwnd,SW_SHOWNORMAL

call gcsva

retn

gcsva: ;Get Child Screen Variables - in progress
retn


   Data for newwin and CWProc (global)

chstyle EQU CS_HREDRAW or CS_VREDRAW or CS_DBLCLKS

LFwcc LABEL DWORD ;LFile Window Child Class structure
DD SIZEOF WNDCLASSEX ; 0 wc.cbSize
DD chstyle ; 4 CHild style
DD OF CWProc ; 8 Child WPROC
DD 0,0 ;0C wc.cbClsExtra, wc.cbWndExtra
DD ? ;14 wc.hinst
cicon DD hicon ;18 LoadIcon,0,IDI_APPLICATION        ;NOTED AS ERROR AFTER POST
DD hcurs ;1C LoadCursor,NULL,IDC_ARROW             ;NOTED AS ERROR AFTER POST
DD hbkbr ;20 CreateSolidBrush,0FF0000h                       ;NOTED AS ERROR AFTER POST
wccmen DD 0 ;24 wc.lpszMenuName
DD OF ChldClass ;28 wc.lpszClassName
DD hiconsm ;2C wc.hIconSm                                                ;NOTED AS ERROR AFTER POST

ChldClass DB "LFChildclass",0
ChildW DB "lfwChild",0
hcwnd DD ? ;handle to child win
hCWnd DD ? ;Handle to Child WiNDow (prob. don't need both)


;;   CWProc

CWProc proc cwphw,msg,wparam,lparam

pushad
or BY [flgs+2],4 ;child exists

mov eax, [cwphw]
mov [hCWnd], eax

mov edx, [wparam]
mov ecx, [lparam]
mov eax, [msg]

cmp eax, WM_DESTROY
  jz CWP_des
cmp eax, WM_PAINT
  jz CWP_pai
cmp eax, WM_KEYDOWN ;100
  jz ckey

cmp eax, WM_SYSKEYDOWN
cmp eax, WM_LBUTTONDOWN ;201
;   jz cmseb
cmp eax, WM_LBUTTONUP ;202
;   jz cmseu
cmp eax, WM_MOUSEMOVE ;200
;   jz cmmov
cmp eax, WM_SETFOCUS
;   jnz CWP_stf ;Last 5 not implemented

CWP_def:
popad
invoke DefWindowProc,cwphw,msg,wparam,lparam
ret

CWP_des:
invoke DestroyWindow,hCWnd
and BY [flgs+2],not 4 ;child does not active
  jmp CWP_end

CWP_pai:
; call cdspl ;not implemented
  jmp CWP_def

CWP_inv:
invoke InvalidateRect, hCWnd,0,0

CWP_end:
popad
xor    eax,eax
ret

;; CKEY Child KEY functions

ckey:
cmp dl, 1Bh ;escape
  jz CWP_des

cmp dl, 8 ;back
  jz ckey_par

cmp dl, 23 ;keypad 1
  jz ckey_test

call erbeep ;beep if none of the above

  jmp CWP_end


ckey_test:
call erbeep
call erbeep
  jmp CWP_end

ckey_par:
invoke SetFocus,hwnd
or eax, eax
  jnz @F
call erbeep
@@:
  jmp CWP_end

CWProc endp


dedndave


raleeper

Quote from: dedndave on August 10, 2011, 06:44:27 AM
could you post the leqmw.asm file ?

Yes.  I think I'll pull all the stuff I use (and maybe stop using some) out of leqm.asm and put it in the main file.  If anyone is kind enough to struggle through my idiosyncratic and poorly documented code in an effor to help, I shouldn't ask him to look at another (even worse) file.

Thank you, ral

raleeper

The equates and macros formerly in leqmw.asm and actually used or likely to be used soon are now in lfw.asm (with some cleanup).

Also, I've corrected the (or an) error in the initialization of LFwcc (in newwin:)

Thanks, ral

dedndave

is this what i am supposed to see ?

(click on image for full-size)


raleeper

Quote from: dedndave on August 10, 2011, 02:56:09 PM
is this what i am supposed to see ?

(click on image for full-size)



Yes!

Attached are zips of:

trans.lfw                The missing rider file.  It needs to be in the location shown by the initialscreen unless it is reassembled with lpRDF containing a different location.
                              Trans.lfw contains command and option tables and a  brief tutorial ("Getting Started")

                               Or it can be anywhere if you edit the path shown on the screen.  To edit the string - 1.  press the down arror twice, so that the leftmost character is green.
                                    2.  Press "e" - the line changes color and you should have a cursor.  Now the left and right arrow keys, back, insert and delete work as in
                                    MS-Word and other wordprocessors.  3. After the line reads the way you want it, press enter.  4.  Press "l" or "L" to load.

lfw.lfw                    The .lfw format version of lfw.asm (or actually, the .asm file is derived directly from the .lfw file)

                                 A settings file (c:\lwopt.ovr) wille be created on normal exit - press escape.  You can block this by pressing "o12[enter]".  (4 keypresses).

ps: "xx" gets you to newwin.
pps: I haven't devoted much attention to the "can't load rider file screen"  I've never seen it before.  Now that I have, I see lots of easy ways to make it better, like
        instructions and alternatives, and eliminating all the status line (at the bottom, white on black or last message red on black) messages except "can't load settings".



raleeper

@dedndave (and all):

In addition to the reference material trans.lfw contains a large amount of old junk and stuff waiting to be filed.  I'll post a cleaned up version next time.  I was so pleased that you had actually run the program that, in my haste to show that it could actually do something useful, I forgot to remove the junk.

Thanks, ral

[later] here's the cleaner version, tho still some junk, especially in the list of files.

raleeper


raleeper

Here are revised files that address the 'cant find Rided File' Problem.

@dedndave:
Did you have any problems assembling?

Thanks, ral

dedndave

i have it up and running
i am just trying to find my way around a little
Zara's birthday is coming up, so i have been taking care of some things for that   :P

i changed the location to the current folder, just to make things easy
lpRDF DB "trans.lfw",0

qWord

raleeper,

there are some problems for me (and I think for some other here) that prevent me from helping you:
- your code is hard to to read - it looks like an disassembly
- it it not clear what your program should do - it is an editor?
- your are using absolute paths in your code (and for loading files)
- supplying a EXE is also offten useful

It may sound hard, but I would suggest you to rewrite the program:
- use masm highlevel contructions, especially for API stuff
- think about your interface: it maybe better to use a 'normal' GUI?
- think about your variables naming convention  :bg
- stay a way from global variables if possible
- split you program meaningful in different files

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

raleeper

@qword

QuoteThere are some problems for me (and I think for some other here) that prevent me from helping you:
- your code is hard to to read - it looks like an disassembly

I can add more explanation in comments.  That would help some.  And eliminate some of the idiosyncracies, such as:
OF    EQU    OFFSET.

Quote- it it not clear what your program should do - it is an editor?

It is an editor and organization tool.
Quote
- your are using absolute paths in your code (and for loading files)

I can fix that.  I will be adding a standard browse for file window soon.

Quote- supplying a EXE is also offten useful

OK. Would any of the following be of any use?

LFW.ILK         57020     08/10/11
LFW.LST          1189     08/10/11
LFW.OBJ        463500     08/10/11
LFW.PDB        459776     08/10/11
LFW.RES           188     08/10/11

QuoteIt may sound hard, but I would suggest you to rewrite the program:
- use masm highlevel contructions, especially for API stuff
- think about your interface: it maybe better to use a 'normal' GUI?
- think about your variables naming convention  BigGrin
- stay a way from global variables if possible
- split you program meaningful in different files

It does sound hard.  But I will consider it.

Thank you, ral

raleeper

Quote from: dedndave on August 10, 2011, 09:41:44 PM

i changed the location to the current folder, just to make things easy
lpRDF DB "trans.lfw",0

Gee.  I didn't realize it was that easy.  I thought I'd have to add a GetCurrentDirectory function, as in DOS, if memory serves.

Thanks, ral

And I've just discovered the purpose (or a use) of the "start in" field in shortcut properties dialogs.  This is great.

Thank you, thank you,