News:

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

CreateDialogParam - Parent Window

Started by JC1, September 16, 2006, 08:28:19 PM

Previous topic - Next topic

JC1

I'm working on a graphical interface for a program, and I'm having some problems with a window, hFunc, created with the CreateDialogParam function.

Let me explain the context:
I have a main window, it is hMainDlg. Then I have a listview control on the left side, hList, whose parent window is hMainDlg. Then I have one more window, hFunc, located on the right of the list view and whose parent window is hMainDlg. hList and hFunc are to be located inside hMainDlg.
I handle the WM_SIZE message in the hMainDlg proc to make those two windows fit peacefuly inside hMainDlg client space:

.elseif uMsg==WM_SIZE ;LOWORD(lParam)=width HIWORD(lParam)=height
.if (hList!=0 && hFunc!=0)
mov eax, lParam
mov cxClientSize, ax
shr eax, 16
mov cyClientSize,ax
invoke MoveWindow, hList, 0, 0, 250, cyClientSize, TRUE               ;move hList position

movzx ebx, cxClientSize
sub bx, 253
invoke MoveWindow, hFunc, 253, 0,ebx, cyClientSize,TRUE            ;move hFunc position
.endif


Everything works fine with the list view control. But the hFunc window isn't moved properly.
It seems that hFunc isn't moved relatively to the upper-left corner of his parent window. The x position is always constant (try double cliking the caption bar or moving the window), and in the y axis hFunc painting begins at the top of the screen, not below the caption bar of hMainDlg.
I've checked in the debugger and CreateDialogParam receives a valid parent HWND and doesn't return any error.  :'(

At WM_CREATE I have:

.elseif uMsg==WM_CREATE
invoke CreateListView, hdlg

    invoke CreateDialogParam, hInstance, SADD("FuncDialog"), hdlg, addr FuncProc, NULL ;hdlg is the HWND passed to the window proc
mov hFunc, eax


You can check this strange behaviour and the remaining code in the file attached. I hope someone can give me some help. I don't know how to fix this.

[attachment deleted by admin]

Shantanu Gadgil

Try the ScreenToClient API.  :bg :bg

Regards,
Shantanu
To ret is human, to jmp divine!

japheth

the problem is that CreateDialogParam usually doesn't create a child window but an "owned" popup/overlapped window. While for a child window screen coordinates are usually given related to the parent window's client coordinates, this is not so in the case of "owned" popup windows.

The solution most likely is: make CreateDialogParam create a child window (IIRC this is done in the STYLE parameter)

JC1

Yes, it can be easily done with ScreenToClient, but in the Win32 documentation, it says that the coordinates used with MoveWindow function are relative to the upper-left corner of the parent window if the HWND passed to the function is from a child window. So, I don't think I have to do something that the WinAPI is supposed to do for me.

japheth, In the resource file I've done:

FuncDialog DIALOGEX 6,6,200,39
STYLE 0xD0000000+WS_CHILD+WS_POPUP
BEGIN

and the behaviour is exactly the same. Am I missing something? Any ideas?

japheth


> STYLE 0xD0000000+WS_CHILD+WS_POPUP

WS_CHILD and WS_POPUP should not be declared both (I dont know for sure, but they may even be mutually exclusive). And IIRC you must also define DS_CONTROL:

> STYLE 0xD0000000+WS_CHILD+DS_CONTROL

although I have forgotten why.

JC1

STYLE WS_VISIBLE+WS_CHILD+DS_CONTROL

Now it works. Thanks for your help