The MASM Forum

General => The Campus => Topic started by: daydreamer on October 20, 2021, 03:28:10 AM

Title: instead of in WM_CREATE: whats right message instead?
Post by: daydreamer on October 20, 2021, 03:28:10 AM
I am working on a GUI program:lots of sending,recieving and other doing buttons settings,
testing with GUI changing code inside WM_LMOUSEBUTTONDOWN:,WM_TIMER: works
but when using same code from in WM_CREATE: nothings happen
place it in some message that comes first when window shows up?

Title: Re: instead of in WM_CREATE: whats right message instead?
Post by: HSE on October 20, 2021, 04:20:01 AM
the source code is missing.
Title: Re: instead of in WM_CREATE: whats right message instead?
Post by: daydreamer on October 20, 2021, 05:14:21 AM
updated first post,the code its about read db strings and change buttons sw_hide,sw_show status
timer slow also works changing it

timer rot randomly changes icons+reappear and disappear buttons

in buttons.inc create buttons and sets pattern of two different colored icons



Title: Re: instead of in WM_CREATE: whats right message instead?
Post by: HSE on October 20, 2021, 05:43:50 AM
Program always have to return from WM_CREATE.

Note, after creategrid:invoke SendMessage, hWnd, WM_LBUTTONDOWN, 0, 0
Title: Re: instead of in WM_CREATE: whats right message instead?
Post by: daydreamer on October 20, 2021, 07:21:19 AM
Quote from: HSE on October 20, 2021, 05:43:50 AM
Program always have to return from WM_CREATE.

Note, after creategrid:invoke SendMessage, hWnd, WM_LBUTTONDOWN, 0, 0
thanks :thumbsup:
Title: Re: instead of in WM_CREATE: whats right message instead?
Post by: daydreamer on October 22, 2021, 07:01:37 AM
how is it possible to have a secondary window with many buttons and use show/hide when needed?
subclass existing window?
Title: Re: instead of in WM_CREATE: whats right message instead?
Post by: Greenhorn on October 22, 2021, 09:14:35 AM
You can store all the stuff you need to manage the buttons in a structure, allocate memory for the struct and save the pointer to it in the window's extra bytes. Within the window procedure you retrieve the pointer from the window's extra bytes to access the buttons.

You need mov  wc.cbClsExtra, sizeof DWORD and Get-/SetWindowLongPtr (https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowlongptra) with argument dwNewLong set to 0.

This is similar to the implementation of (custom) controls. Here's an example of custom controls, just apply this technique to your main window ...
Custom Controls (http://www.catch22.net/tuts/win32/custom-controls#)

Cheers
Greenhorn

P.S. Why not just start a new process ?
P.P.S. For LoadImage the LR_SHARED flag is very useful if you load the same image more than once ...
Title: Re: instead of in WM_CREATE: whats right message instead?
Post by: fearless on October 22, 2021, 09:34:03 AM
Yes i do something similar with ModernUI controls except i use two dwords of extra space, one for a pointer to allocated memory for a structure of internal properties I use for the control and one for a pointer to allocated memory for a structure of external properties that is used by the control that can be modified by the user. After some experimentation and use I found that allocating more than 40 bytes, in practice should be fine, but officially isnt recommended and I found strange bugs with allocating lots of memory on a couple of occasions: See https://fearless.gitbook.io/creating-controls-in-assembler/control-properties for details.
Title: Re: instead of in WM_CREATE: whats right message instead?
Post by: Biterider on October 22, 2021, 05:09:37 PM
Hi fearless
That is really cool https://fearless.gitbook.io/creating-controls-in-assembler/ (https://fearless.gitbook.io/creating-controls-in-assembler/)  :thumbsup: :thumbsup: :thumbsup:

Biterider
Title: Re: instead of in WM_CREATE: whats right message instead?
Post by: fearless on October 22, 2021, 06:45:09 PM
Thanks Biterider


Its a few years old now (2017/18 i think) when it was on the gitbooks.com site - since changed to gitbooks.io with a free and a freeium/premium option now for hosting projects. Had a option to import the older project over, so done that so that its still available online to view - the epub/pdf options probably dont work now.


Still, it might be useful for someone. Also the corresponding simple button control referenced in the gitbook is on my github as well: https://github.com/mrfearless/SimpleButton
Title: Re: instead of in WM_CREATE: whats right message instead?
Post by: jj2007 on October 22, 2021, 07:13:01 PM
Quote from: Biterider on October 22, 2021, 05:09:37 PM
Hi fearless
That is really cool https://fearless.gitbook.io/creating-controls-in-assembler/ (https://fearless.gitbook.io/creating-controls-in-assembler/)  :thumbsup: :thumbsup: :thumbsup:

A book on controls - cool indeed :thumbsup:
Title: Re: instead of in WM_CREATE: whats right message instead?
Post by: fearless on October 22, 2021, 07:38:41 PM
Thanks JJ

I thought people knew about it already, but maybe I forgot to post up about it. Anyhow, I also added a link in my profile to it as well. Plus its accessible via a link on the original github repo that stores the content for the gitbook: https://github.com/mrfearless/creating-controls-in-assembler
Title: Re: instead of in WM_CREATE: whats right message instead?
Post by: daydreamer on October 23, 2021, 12:43:02 AM
thanks greenhorn :thumbsup:
thanks fearless  :thumbsup:
seem like I need to make several wndproc version:labyrinth,tactics grid

Title: Re: instead of in WM_CREATE: whats right message instead?
Post by: BugCatcher on October 23, 2021, 03:14:18 AM
With many button programs, I use a dlg program with child dlgs. Buttons in the resource file that have unique identifiers then use equates to give them understandable names. Can use any dlg with handle.
                  invoke   GetDlgItem,hWin,StartNflSeasonButton hWin=dlg handle
            invoke   ShowWindow,eax,SW_HIDE
            invoke   GetDlgItem,hWin,StartCollegeSeasonButton
            invoke   ShowWindow,eax,SW_HIDE
            invoke   GetDlgItem,hWin,EndGameButton
            invoke   ShowWindow,eax,SW_SHOW         
Title: Re: instead of in WM_CREATE: whats right message instead?
Post by: daydreamer on October 23, 2021, 06:21:19 PM
But at her thanks :thumbsup:
What about start with mdi instead?
Title: Re: instead of in WM_CREATE: whats right message instead?
Post by: daydreamer on October 26, 2021, 05:07:10 AM
what about have one main app and use many files to move away from hardcoded data and launch tactics program when needed and it reads first from a file with "pointers",which setup of enemies its time to meet
it updates data to files while it runs and when returning to main app,the little squad you are commanding are updated with loss/gains from the fight
got rotate proc working,so part 3x3 of labyrinth can "rotate",so it can have 4 ways possible moves thru labyrinth
Title: Re: instead of in WM_CREATE: whats right message instead?
Post by: hutch-- on October 27, 2021, 12:00:19 PM
Magnus,

WM_CREATE in only used in one place and it is only called once, in the WndProc.