Use PropertySheet as main application


As the title refers, to add initial function and IDOK,IDCANCEL messages,

In Visual C++:
I create subclass from CPropertySheet, then , I can deal with those messages by OnInitDialog(),OnButtonOK().

But in MASM:
I use the API function "PropertySheet()", where should I deal with those messages?

Thank you.

(Is there any code snippet?)

Here is the sample:

;Main Proc
;///////////////////////////////////////////////////////////////////////////////

invoke GetModuleHandle, NULL
mov g_hInstance, eax
invoke GetCommandLine
mov g_pCommandLine, eax

;--Init PROPSHEETPAGE,create pages
invoke CreatePropertySheetPage, addr stPSP
;--Init PROPSHEETHEADER, add pages, show the PropertySheet as the main window.
invoke PropertySheet, addr stPSH

invoke ExitProcess, eax


;OptionProc
;///////////////////////////////////////////////////////////////////////////////
OptionProc proc hWnd, uMsg, wParam, lParam
......
ret
OptionProc endp


;PageProc
;///////////////////////////////////////////////////////////////////////////////
PageProc proc hWnd, uMsg, wParam, lParam
......
ret
PageProc endp
Posted on 2004-10-21 10:37:41 by seasea
Ron Thomas has an example how to use a PropertySheet
look here : http://www.rbthomas.freeserve.co.uk/

also on the board here

http://www.asmcommunity.net/board/viewtopic.php?t=2371

u already started correct (i assume u pasted only a snipped )
just react in the PageProc?s to the messages
Posted on 2004-10-21 14:06:36 by Allanon
Hi, Allanon, thanks.

----------------------------------------------------------------------
I can't access the web, maybe it has some troubles.
http://www.rbthomas.freeserve.co.uk/

----------------------------------------------------------------------
And I read the post:
http://www.asmcommunity.net/board/viewtopic.php?t =2371
I can do the Initial Message of PropertySheet in the creation of the page.
But, I don't think that is a good soluation.
And, I want to do some work in the message of WM_PAINT of the PROPERTYSHEET.
And, I want to do many other work.

-----------------------------------------------------------------------
In Visual C++:
I create subclass from CPropertySheet, then , I can deal with those messages by

OnInitDialog(),OnButtonOK(),OnPaint(),OnSysCommand

This is the VC++ sample:

// class CPropertyMain : public CPropertySheet

BOOL CPropertyMain::OnInitDialog()
{
SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), TRUE);
::SetWindowLong(m_hWnd, GWL_STYLE, GetStyle() | WS_MINIMIZEBOX);
CMenu *pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu)
{
pSysMenu->InsertMenu(0, MF_BYPOSITION | MF_STRING, SC_RESTORE, "Restore(&R)");
pSysMenu->EnableMenuItem(SC_RESTORE, MF_BYCOMMAND | MF_GRAYED);
}
..................
}

void CPropertyMain::OnPaint()
{
CPaintDC dc(this); // device context for painting
//Paint the " MASM32 " at the left-bottom corner
......
}

void CPropertyMain::OnButtonOK()
{
// Deal with the IDOK message
.....
}

So, I can complie my VC++ program like the image like the attach file

--------------------------------------------------------------------------
Now, do you know , What I want?

Where should I deal with those message, so I can get the program like that compiled in VC.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

------------------------------------------------------------------------------------------

Thank you and others.
Posted on 2004-10-22 10:53:56 by seasea
Once more, sorry.

Does anyone has some suggestions?

Thanks.
Posted on 2004-10-27 09:45:09 by seasea
hallo seasea,

honestly said i don?t understand ur problem :?

ther?s no real difference
first create ur Propertsheetpages, the header and the control
and than u can react on any msg u want to use

for ex. u created first 3 Propertysheetpages
and filled all the Pointers to the dialog box procedures for the pages
for example u called them DialogFunc1,DialogFunc2,DialogFunc3

than u can react in the procedure DialogFunc1





DialogFunc1 proc hwin:HWND, uMsg:DWORD, wParam:WPARAM, lParam:LPARAM

mov eax, uMsg

.IF eax==WM_PAINT

your coding here

.ELSEIF eax==WM_NOTIFY

your coding here

.ELSEIF eax==WM_COMMAND

your coding here
.ELSEIF eax==WM_INITDIALOG

your coding here

.Endif
return FALSE

DialogFunc1 endp


does this help you ?
Posted on 2004-10-28 10:45:15 by Allanon
hallo seasea,

honestly said i don?t understand ur problem :?

ther?s no real difference
first create ur Propertsheetpages, the header and the control
and than u can react on any msg u want to use

for ex. u created first 3 Propertysheetpages
and filled all the Pointers to the dialog box procedures for the pages
for example u called them DialogFunc1,DialogFunc2,DialogFunc3

than u can react in the procedure DialogFunc1





DialogFunc1 proc hwin:HWND, uMsg:DWORD, wParam:WPARAM, lParam:LPARAM

mov eax, uMsg

.IF eax==WM_PAINT

your coding here

.ELSEIF eax==WM_NOTIFY

your coding here

.ELSEIF eax==WM_COMMAND

your coding here
.ELSEIF eax==WM_INITDIALOG

your coding here

.Endif
return FALSE

DialogFunc1 endp


does this help you ?


Thank you.
Sorry for my poor English.


What I want is to design the interface use PropertySheet by MASM32, like the image I posted (not Tab Ctrl).

The difficulity is, I don't know how to draw the text "MAMS32" at the area of the PropertySheet.

But , I can do it use VC++ use the method as fllows:
Create a subclass from CPropertySheet, then , I can deal with those messages by OnInitDialog(),OnButtonOK(),OnPaint(),OnSysCommand()...

So, if anyone use PropertySheet in masm32 and design the interface like the image I posted, then , that's want I want.

Thanks
Posted on 2004-10-29 08:28:46 by seasea
ah now i got what u want ;)

oke i think most elegant way would be to subclass it and than go on ..

simple and also working, but for sure not the best way ;)
is the following get the handle of the parent window and either set the text than as a simple static text or paint it ..
i included a modified version of the above posted link
Posted on 2004-10-31 13:05:15 by Allanon
Allanon, thank you.

Than's what I want !.

And, I readed the MSDN, found the structure PROPSHEETHEADER has a member:
PFNPROPSHEETCALLBACK pfnCallback;
Yes, I think I can do with those messages in the callback function. I will try it, and I will post a sample if everything does ok.
Posted on 2004-11-01 07:59:30 by seasea
Hello, Allanon:

After I read the structure "PROPSHEETHEADER" in the MSDN, I don't think your method is the best.
One of the member of "PROPSHEETHEADER" is:
PFNPROPSHEETCALLBACK pfnCallback
Yes, I can write my own Sheet proc,for example:

PropertySheetProc proc hWnd:HWND, uMsg:DWORD, lParam:LPARAM
mov eax, uMsg
.if eax == PSCB_INITIALIZED
invoke LoadIcon, g_hInstance, IDI_Main
invoke SendMessage, hWnd, WM_SETICON, ICON_BIG, eax
invoke CreateWindowEx..... ;//Create the Static window in the left-bottom area.
;????????????????????????????????????????
; .elseif eax == WM_COMMAND
; invoke MessageBox, hWnd, offset szText, offset szTitle, MB_OK
; .elseif eax == WM_PAINT
; invoke SelfPaint.........
;????????????????????????????????????????
.endif
ret
PropertySheetProc endp

So,I can deal with the initial code here, but, the MSDN said:

uMsg
Message being received. This parameter is one of the following values:
PSCB_INITIALIZED Indicates that the property sheet is being initialized. The lParam value is zero for this message.
PSCB_PRECREATE
That is, neither your method nor mine, can deal with the other messages such as WM_COMMAND or WM_PAINT or others.


Here is my VC++ example,I derive a subclass CPropertyMain from CPropertySheet, then I can deal with all the messages, do everything I can do. For example:
1. By deal with the WM_PAINT message, I drew the text "VC++6" at the left-bottom area (not use the Static control).
2. I can deal with the IDOK command message, so, when a user click the IDOK button, the program won't exit.
3. And the others...

If you don't use VC++ developer, it doesn't matter. you can look at the PropertyMain.cpp, and run the PSheet.exe, then , you will realize what I want to do.

What I want to do is:

I can deal with all the messages of the PropertySheet.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Sorry for my pool English.

Thank you, and others.
Posted on 2004-11-02 09:32:19 by seasea
i know that my method there isn?t the best (mentioned it also) :lol:
was a quick and dirty hack only ;)
Posted on 2004-11-02 10:59:11 by Allanon
i'm not sure since i never had the real use for somethin like u want
but i think u might try as dwFlags in the PROPSHEETHEADER

PSH_MODELESS
Causes the PropertySheet function to create the property sheet as a modeless dialog box instead of as a modal dialog box. When this flag is set, PropertySheet returns immediately after the dialog box is created, and the return value from PropertySheet is the window handle to the property sheet dialog box.

For the purpose u want u might have also a closer look here
PropertySheet Function

By default, the PropertySheet function creates a modal dialog box. If the dwFlags member of the PROPSHEETHEADER structure specifies the PSH_MODELESS flag, PropertySheet creates a modeless dialog box and returns immediately after it is created. In this case, the PropertySheet return value is the window handle to the modeless dialog box.

For a modeless property sheet, your message loop should use PSM_ISDIALOGMESSAGE to pass messages to the property sheet dialog box. Your message loop should use PSM_GETCURRENTPAGEHWND to determine when to destroy the dialog box. When the user clicks the OK or Cancel button, PSM_GETCURRENTPAGEHWND returns NULL. You can then use the DestroyWindow function to destroy the dialog box.
Posted on 2004-11-02 11:04:34 by Allanon
i'm not sure since i never had the real use for somethin like u want
but i think u might try as dwFlags in the PROPSHEETHEADER

PSH_MODELESS
.............................
.........................
.



Allanon, thank you very much .

I'll try it.
Posted on 2004-11-03 08:32:59 by seasea

i'm not sure since i never had the real use for somethin like u want
but i think u might try as dwFlags in the PROPSHEETHEADER

PSH_MODELESS
..........................
..........................



Allanon, I think you're right.

After I read the topics about PropertySheet in MSDN carefully,to create an application by using PropertySheet as the main window,maybe the PSH_MODELESS is the only method.
But, how to create an application that the main window is a modeless dialog, and how do the message loop.
Then, I read the CPropertySheet MFC source, but, I still have no ideas.
How stupid I'm. ha...

Allanon, if you had any time, would you give me a snippet ?
Thank you .
Posted on 2004-11-14 08:52:58 by seasea
i assume the msg procedure isn?t much different then the "normal" one



.WHILE TRUE
invoke GetMessage, ADDR msg,NULL,0,0
.BREAK .IF (!eax)
invoke SendMessage, hDlg,PSM_ISDIALOGMESSAGE,0, ADDR msg
.IF eax ==FALSE
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
.ENDIF
.ENDW
mov eax,msg.wParam
ret


following the MSDN u might add into the loop also PSM_GETCURRENTPAGEHWND to check when the user clicks the OK or Cancel button
Posted on 2004-11-16 01:44:41 by Allanon
ah blah forget that about the modless Propertysheet
just use pfnCallback, guess that should do everythin also fine
included a modified sample
Posted on 2004-11-16 04:14:01 by Allanon
i assume the msg procedure isn?t much different then the "normal" one



.WHILE TRUE
invoke GetMessage, ADDR msg,NULL,0,0
.BREAK .IF (!eax)
invoke SendMessage, hDlg,PSM_ISDIALOGMESSAGE,0, ADDR msg
.IF eax ==FALSE
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
.ENDIF
.ENDW
mov eax,msg.wParam
ret


following the MSDN u might add into the loop also PSM_GETCURRENTPAGEHWND to check when the user clicks the OK or Cancel button


Allanon, thank you again !

1.
Let me try it.

2. wizdemo is a module propertysheet, and the PropWndProc can't get the other messages ,such as WM_COMMAND. So, wizdemo almost is the same as the code before .

Thanks.
Posted on 2004-11-17 11:08:23 by seasea
well PropWndProc handles the messages that go to the "main" window
the other messages are handled in the dialog processes
so u can use there of course WM_COMMAND

if that's still not what u want ... i'm really lost and give up .. dunno than
maybe someone else knows what he wants ... :? :?
Posted on 2004-11-18 02:28:52 by Allanon
had a copy / paste bug in the last version anyways ..
so here also one with ur WM_COMMAND
Posted on 2004-11-19 03:36:13 by Allanon
Allanon, now I had finished this program:

1. Use the PropertySheet as the main window of the application.
2. The window has system menu and icon.
3. It can deal with WM_COMMAND message and others.
4. It draw some 3D text at the left-bottom area of the PropertySheet.

  When I wanted to  use SetWindowLog(..) to make the PropertySheet use my own procedure, I didn't how can I do it.
  But when I knew how to use PROPSHEETHEADER.pfnCallback, I forgot to use SetWindowLog(..).
  ha, ha, ha....

  Now, erverthing is OK !

  You're skiillfull and clever.
  You're warmhearted.

  Thank you.
Attachments:
Posted on 2004-11-20 00:28:10 by seasea