Powerbasic Museum 2020-B

IT-Consultant: Patrice Terrier => SDK Programming => Topic started by: Eros Olmi on August 07, 2007, 11:35:13 PM

Title: Take control of your window code
Post by: Eros Olmi on August 07, 2007, 11:35:13 PM
Patrice,

thanks a lot for this fantastic learning code at http://www.jose.it-berater.org/smfforum/index.php?topic=1180.0
Really a big source of learning and thinking on how to make things on UI side.

A little note: on my box (WinXP Sp2) when I minimixe and than maximixe again, there is a graphic gap un upper left side, like a graphic repetition of part of the button graphic. Can it be?

Thanks again.
Eros
Title: Re: Take control of your window code
Post by: Petr Schreiber on August 08, 2007, 09:18:24 AM
Hi,

I'd like to thank too for the sample, it is simply amazing.
I can confirm this redraw problem when minimize-maximize too. But when I click to "Restore" it is again correct..

Bye,
Petr
Title: Re: Take control of your window code
Post by: Patrice Terrier on August 08, 2007, 10:34:03 AM
I don't see this problem on my computer(s)

But this is typically a Windows animation behavior occuring while the form is maximized, because at the time the AnchorEnum callback is being used, the new button location (in our case %ANCHOR_CENTER) the pr RECT structure has not been yet updated.

There are several solutions to this problem, either use a small ApiSLEEP or use MoveWindow instead of CALL ShowWindow(hWnd, %SW_MAXIMIZE).

In any case the change must be done there:


'// We process our custom system buttons command there.
FUNCTION zButtonSysCommand (BYVAL hWnd AS LONG, BYVAL wParam AS LONG) AS LONG
    LOCAL Done AS LONG
    Done = 0
    SELECT CASE LONG CINT(LOWRD(wParam))
    CASE %ID_CLOSE
         CALL SendMessage(hWnd, %WM_CLOSE, 0, 0)
         Done = -1
    CASE %ID_MAXIMIZE
         CALL ShowWindow(GetDlgItem(hWnd, %ID_RESTORE), %SW_SHOW)
         CALL ShowWindow(GetDlgItem(hWnd, %ID_MAXIMIZE), %SW_HIDE)
         CALL zUpdateWindow(GetDlgItem(hWnd, %ID_RESTORE), 0)
         CALL ShowWindow(hWnd, %SW_MAXIMIZE)

'------
         CALL zDrawBackground()
         CALL EnumChildWindows(hWnd, CODEPTR(AnchorEnum), 0) ' <-------
'------
         
         Done = -1
    CASE %ID_RESTORE
         CALL ShowWindow(GetDlgItem(hWnd, %ID_MAXIMIZE), %SW_SHOW)
         CALL ShowWindow(GetDlgItem(hWnd, %ID_RESTORE), %SW_HIDE)
         CALL zUpdateWindow(GetDlgItem(hWnd, %ID_MAXIMIZE), 0)
         CALL ShowWindow(hWnd, %SW_RESTORE)

         CALL zDrawBackground()
         CALL EnumChildWindows(hWnd, CODEPTR(AnchorEnum), 0)

         Done = -1
    CASE %ID_MINIMIZE
         CALL ShowWindow(hWnd, %SW_MINIMIZE)
         Done = -1
    END SELECT
    FUNCTION = Done
END FUNCTION


Title: Re: Take control of your window code
Post by: Patrice Terrier on August 08, 2007, 10:52:42 AM
Please, could you try this, and tell me if it solves the problem?

In zButtonSyscomand change CASE %ID_MAXIMIZE to this:


    CASE %ID_MAXIMIZE
         CALL ShowWindow(hWnd, %SW_MAXIMIZE)
         CALL ShowWindow(GetDlgItem(hWnd, %ID_RESTORE), %SW_SHOW)
         CALL ShowWindow(GetDlgItem(hWnd, %ID_MAXIMIZE), %SW_HIDE)

         CALL zDrawBackground()
         CALL EnumChildWindows(hWnd, CODEPTR(AnchorEnum), 0)
         
         Done = -1


Thank you

Patrice Terrier
www.zapsolution.com
Title: Re: Take control of your window code
Post by: Eros Olmi on August 08, 2007, 11:19:44 AM
Sorry Patrice but problem still there.

In the upper left corner of the window is is showed to lower right image of the button. It seems like when restoring the window, the middle scren button is first drawn partially in the upper left side of the window and than moved in the center of the window. Can it be?

Regards
Eros
Title: Re: Take control of your window code
Post by: Patrice Terrier on August 08, 2007, 11:43:46 AM
Ok, I see it now, I did not understood first how to reproduce the behavior.
But now that I am able to reproduce it myself, consider it as solved ;)
Title: Here is the solution
Post by: Patrice Terrier on August 08, 2007, 11:57:56 AM
To fix the problem.

In AnchorEnum add
IF IsIconic(zMainWindow(0)) THEN FUNCTION = %FALSE: EXIT FUNCTION like this:

'// Anchor enum callback functio.n
FUNCTION AnchorEnum (BYVAL hWnd AS LONG, BYVAL lParam AS LONG) AS LONG

    IF IsIconic(zMainWindow(0)) THEN FUNCTION = %FALSE: EXIT FUNCTION

    'LOCAL zChildClass AS ASCIIZ * 32
    LOCAL pr AS RECT, rc AS RECT, pZP AS LONG
    LOCAL x, y, xW, yH AS LONG


In zDrawBackground add
IF IsIconic(hMain) THEN EXIT SUB like this :

'// Draw our custom background there
SUB zDrawBackground()
    LOCAL hMain AS LONG, hIC AS LONG, hDCmem AS LONG, rc AS RECT
    hMain = zMainWindow(0)
    IF IsIconic(hMain) THEN EXIT SUB
    CALL GetClientRect(hMain, rc)


Please let me know?
Title: Re: Take control of your window code
Post by: Eros Olmi on August 08, 2007, 12:25:22 PM
Got it, perfect  ;)

Thanks a lot
Eros
Title: Re: Take control of your window code
Post by: Patrice Terrier on August 10, 2011, 06:25:53 PM
The corrupted JPEG file attached to the first post of this thread has been removed (because of the "Server Collapse").

...