• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

Take control of your window code

Started by Eros Olmi, August 07, 2007, 11:35:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Eros Olmi

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
thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Petr Schreiber

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
AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com

Patrice Terrier

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


Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

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
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Eros Olmi

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
thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Patrice Terrier

#5
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 ;)
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

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?
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Eros Olmi

thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Patrice Terrier

The corrupted JPEG file attached to the first post of this thread has been removed (because of the "Server Collapse").

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com