Announcement

Collapse
No announcement yet.

Any cure for this ...?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Rodney Hicks
    replied
    I haven't been quite sure what the goal of this is, since it must be a stepping stone to some more productive application. If it is your intention to use PBCC then these options, especially Dave's last one, look like the ticket.
    If you were using PBWin then I would suggest using the CONTROL ADD GRAPHIC to find your optimum Font in the similar manner but on a dialog instead of separate windows.

    Leave a comment:


  • Dave Biggs
    replied
    Gert,

    Looks like your solution using a Bitmap is the best but just for future reference..
    It is possible to hide the first window from the taskbar by making it a ToolWindow like this..
    Code:
    'Delay End of first Graphic Window until second is started (keep GUI 'alive').
    'Make first window w/ ToolWindow style - not visible on the TaskBar
    'Make with 0x0 size to make window 1 invisble
    #COMPILE EXE
    #DIM ALL
    #IF %DEF(%PB_CC32)
        #BREAK ON
        #CONSOLE OFF
    #ENDIF
     
    #INCLUDE "Win32Api.Inc"
    GLOBAL hHook AS DWORD 
    '------------------------------------------------------------------------------
    FUNCTION HookGFXWindow(BYVAL lMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
     
      IF lMsg = %HCBT_CREATEWND THEN      ' wParam has handle of Window about to be created
        UnhookWindowsHookEx hHook
        SetWindowLong wParam, %GWL_EXSTYLE, (GetWindowLong (wParam, %GWL_EXSTYLE) Or %WS_Ex_ToolWindow)
      END IF
     
     FUNCTION = 0
    END FUNCTION
    '------------------/HookGFXWindow 
     
    FUNCTION PBMAIN
        LOCAL hGW1, hGW2, hFont1 AS DWORD
        LOCAL sTitle$, ncWidth!, ncHeight!
        FONT NEW "Arial", 32, 1, 0, 0, 0 TO hFont1
     
        hHook = SetWindowsHookEx(%WH_CBT, CodePtr(HookGFXWindow), GetModuleHandle(""), 0)
        GRAPHIC WINDOW "Test_focus: Green", 0, 0, 0, 0 TO hGW1 '(Invisible)
        GRAPHIC ATTACH hGW1, 0
        GRAPHIC SET FONT hFont1
        GRAPHIC CHR SIZE TO ncWidth!, ncHeight!
     
        sTitle = "Char size of Arial 32pt Bold: "+ str$(ncWidth!) + ", " + str$(ncHeight!)
        GRAPHIC WINDOW sTitle, 400, 400, 350, 100 TO hGW2
        GRAPHIC WINDOW END    ' << NB hGW1 End here to keep GUI 'alive' else loose focus, flash taskbar icon etc.
        GRAPHIC ATTACH hGW2, 0
        GRAPHIC CLEAR %RED
        GRAPHIC PRINT " Press any key ... (default font in this window)"
        GRAPHIC WAITKEY$
        GRAPHIC WINDOW END
     
    END FUNCTION
    '------------------------------------------------------------------------------

    Leave a comment:


  • Gert Voland
    replied
    GRAPHIC WINDOW "", 0, 0, 0, 0 TO hGW1 '(No caption - no titlebar) Will fix that
    Yes, then we see no GW. A taskbar icon will still appear, though (without caption text).


    The best is to use BITMAP instead of WINDOW. The BITMAP needs to be ATTACHed (and ENDed)
    and one can do the size measurement (and may be other graphic manipulations).
    No change of the screen, no taskbar icon, no iconized and flashing GW.

    Thank you guys for the discussion

    Rgds, Gert.

    Leave a comment:


  • Rodney Hicks
    replied
    This allows you to see each of the fonts.
    Code:
    #COMPILE EXE
    #IF %DEF(%PB_CC32)
        #BREAK ON
        #CONSOLE OFF
    #ENDIF
    '#CONSOLE OFF
    DEFLNG a-z
    GLOBAL CarH(),CarW(),Tw(), Th() AS DOUBLE
    GLOBAL fnt(),hwin() AS LONG
    FUNCTION PBMAIN () AS LONG
     STATIC caption() AS STRING
     LOCAL XX AS LONG
     DIM caption(6)
     DIM fnt(6),CarH(6), CarW(6), Tw(6), Th(6), hwin(6)
     DESKTOP GET CLIENT TO PixW,PixH
     GRAPHIC BITMAP NEW PixW,PixH TO hwin(0)
     GRAPHIC ATTACH hwin(0),0,REDRAW
     FONT NEW "COURIER NEW",10,0,0,0,0 TO fnt(1)
     caption(1)="COURIER NEW"
     GRAPHIC SET FONT fnt(1)
     GRAPHIC CHR SIZE TO CarW(1),CarH(1)
     GRAPHIC TEXT SIZE "Text size for Courier New 10" TO Tw(1),Th(1)
     FONT END fnt(1)
     FONT NEW "COURIER NEW",12,0,0,0,0 TO fnt(2)
     caption(2)="COURIER NEW"
     GRAPHIC SET FONT fnt(2)
     GRAPHIC CHR SIZE TO CarW(2),CarH(2)
     GRAPHIC TEXT SIZE "Text size for Courier New 12" TO Tw(2),Th(2)
     FONT END fnt(2)
     FONT NEW "COURIER NEW",14,0,0,0,0 TO fnt(3)
     caption(3)="COURIER NEW"
     GRAPHIC SET FONT fnt(3)
     GRAPHIC CHR SIZE TO CarW(3),CarH(3)
     GRAPHIC TEXT SIZE "Text size for Courier New 14" TO Tw(3),Th(3)
     FONT END fnt(3)
     FONT NEW "ARIAL",10,0,0,0,0 TO fnt(4)
     caption(4)="ARIAL"
     GRAPHIC SET FONT fnt(4)
     GRAPHIC CHR SIZE TO CarW(4),CarH(4)
     GRAPHIC TEXT SIZE "Text size for Arial 10" TO Tw(4),Th(4)
     FONT END fnt(4)
     FONT NEW "ARIAL",32,1,0,0,0 TO fnt(5)
     caption(5)="ARIAL"
     GRAPHIC SET FONT fnt(5)
     GRAPHIC CHR SIZE TO CarW(5),CarH(5)
     GRAPHIC TEXT SIZE "Text size for Arial 32 Bold" TO Tw(5),Th(5)
     FONT END fnt(5)
     FONT NEW "TIMES NEW ROMAN",14,2,0,0,0 TO fnt(6)
     caption(6)="TIMES NEW ROMAN"
     GRAPHIC SET FONT fnt(6)
     GRAPHIC CHR SIZE TO CarW(6),CarH(6)
     GRAPHIC TEXT SIZE "Text size for Times New Roman 14 Italic" TO Tw(6),Th(6)
     FONT END fnt(6)
     GRAPHIC BITMAP END
     FOR XX=1 TO 6
       IF XX=5 THEN ITERATE FOR
       GRAPHIC WINDOW "TIMES NEW ROMAN",1,1,Tw(XX),Th(XX) TO hwin(XX)
       GRAPHIC ATTACH hwin(XX),0,REDRAW
       GRAPHIC SET LOC 100,100
       FONT NEW "TIMES NEW ROMAN",14,2,0,0,0 TO fnt(XX)
       GRAPHIC SET FONT fnt(XX)
       GRAPHIC CLEAR %WHITE
       GRAPHIC COLOR %BLACK,%WHITE
       GRAPHIC SET POS(1,1)
       GRAPHIC PRINT "Text size for Times New Roman 14 Italic"
       GRAPHIC REDRAW
       'GRAPHIC WINDOW "",0,0,0,0 TO hwin(xx)   'UNCOMMENT FOR THE FUN OF IT
       GRAPHIC WAITKEY$      'COMMENT OUT WITH WINDOW END
       GRAPHIC WINDOW END    'COMMENT OUT WITH WAITKEY$
     NEXT XX
     
     GRAPHIC WINDOW "ARIAL 32 BOLD",1,1,Tw(5),Th(5) TO hwin(5)
     GRAPHIC ATTACH hwin(5),0,REDRAW
     GRAPHIC SET LOC 300,300
     FONT NEW "ARIAL",32,2,0,0,0 TO fnt(5)
     GRAPHIC SET FONT fnt(5)
     GRAPHIC CLEAR %WHITE
     GRAPHIC COLOR %BLACK,%WHITE
     GRAPHIC SET POS(1,1)
     GRAPHIC PRINT "Text size for Arial 32 Bold"
     GRAPHIC REDRAW
     GRAPHIC REDRAW
     GRAPHIC WAITKEY$
     GRAPHIC WINDOW END
    END FUNCTION

    Leave a comment:


  • Manuel Valdes
    replied
    Code:
     
    #COMPILE EXE
    #CONSOLE OFF
    DEFLNG a-z
    GLOBAL CarH(),CarW(),Tw(), Th() AS DOUBLE
    GLOBAL fnt(),hwin() AS LONG
     
    FUNCTION PBMAIN () AS LONG
     LOCAL PixW, PixH AS LONG
     DIM fnt(6),CarH(6), CarW(6), Tw(6), Th(6), hwin(6)
     DESKTOP GET CLIENT TO PixW,PixH
     GRAPHIC BITMAP NEW PixW,PixH TO hwin(0)
     GRAPHIC ATTACH hwin(0),0,REDRAW
     FONT NEW "COURIER NEW",10,0,0,0,0 TO fnt(1)
     GRAPHIC SET FONT fnt(1)
     GRAPHIC CHR SIZE TO CarW(1),CarH(1)
     GRAPHIC TEXT SIZE "Text size for Courier New 10" TO Tw(1),Th(1)
     FONT NEW "COURIER NEW",12,0,0,0,0 TO fnt(2)
     GRAPHIC SET FONT fnt(2)
     GRAPHIC CHR SIZE TO CarW(2),CarH(2)
     GRAPHIC TEXT SIZE "Text size for Courier New 12" TO Tw(2),Th(2)
     FONT NEW "COURIER NEW",14,0,0,0,0 TO fnt(3)
     GRAPHIC SET FONT fnt(3)
     GRAPHIC CHR SIZE TO CarW(3),CarH(3)
     GRAPHIC TEXT SIZE "Text size for Courier New 14" TO Tw(3),Th(3)
     FONT NEW "ARIAL",10,0,0,0,0 TO fnt(4)
     GRAPHIC SET FONT fnt(4)
     GRAPHIC CHR SIZE TO CarW(4),CarH(4)
     GRAPHIC TEXT SIZE "Text size for Arial 10" TO Tw(4),Th(4)
     FONT NEW "ARIAL",32,1,0,0,0 TO fnt(5)
     GRAPHIC SET FONT fnt(5)
     GRAPHIC CHR SIZE TO CarW(5),CarH(5)
     GRAPHIC TEXT SIZE "Text size for Arial 32 Bold" TO Tw(5),Th(5)
     FONT NEW "TIMES NEW ROMAN",14,2,0,0,0 TO fnt(6)
     GRAPHIC SET FONT fnt(6)
     GRAPHIC CHR SIZE TO CarW(6),CarH(6)
     GRAPHIC TEXT SIZE "Text size for Times New Roman 14 Italic" TO Tw(6),Th(6)
     
     GRAPHIC BITMAP END
     
     FONT END fnt(1)
     FONT END fnt(2)
     FONT END fnt(3)
     FONT END fnt(4)
     
    GRAPHIC WINDOW "TIMES NEW ROMAN",1,1,Tw(6),Th(6) TO hwin(6)
     GRAPHIC ATTACH hwin(6),0,REDRAW
     GRAPHIC SET LOC 100,100
     FONT NEW "TIMES NEW ROMAN",14,2,0,0,0 TO fnt(6)
     GRAPHIC SET FONT fnt(6)
     GRAPHIC CLEAR %WHITE
     GRAPHIC COLOR %BLACK,%WHITE
     GRAPHIC SET POS(1,1)
     GRAPHIC PRINT "Text size for Times New Roman 14 Italic"
     GRAPHIC REDRAW
     
     GRAPHIC WINDOW "ARIAL 32 BOLD",1,1,Tw(5),Th(5) TO hwin(5)
     GRAPHIC ATTACH hwin(5),0,REDRAW
     GRAPHIC SET LOC 300,300
     FONT NEW "ARIAL",32,2,0,0,0 TO fnt(5)
     GRAPHIC SET FONT fnt(5)
     GRAPHIC CLEAR %WHITE
     GRAPHIC COLOR %BLACK,%WHITE
     GRAPHIC SET POS(1,1)
     GRAPHIC PRINT "Text size for Arial 32 Bold"
     GRAPHIC REDRAW
     GRAPHIC REDRAW
     GRAPHIC WAITKEY$
     GRAPHIC WINDOW END
    END FUNCTION
    Last edited by Manuel Valdes; 9 Aug 2009, 11:34 AM. Reason: Fonts can't be ended while in use

    Leave a comment:


  • Manuel Valdes
    replied
    Actually a GW can't be resized after it was created, so it would be necessary to give it the void caption and the null dimensions from the very begining. So the second GW gets the focus and pop up, but a void icon will be the same in the task bar. If the first GW is just for dimensioning purposes, then I am afraid the bitmap is a better solution.
    Last edited by Manuel Valdes; 8 Aug 2009, 10:14 PM.

    Leave a comment:


  • Rodney Hicks
    replied
    You're right Dave. In my last post I had forgotten to comment out the GRAPHIC WAITKEY$, and when I did, it was right back where he started.
    Your line of code has to precede the GRAPHIC WINDOW END statement.

    This seems to be inconsistent with the following from the GRAPHIC WINDOW statement:
    Due to the nature of a GRAPHIC WINDOW and its contents, it may not be resized. If a new size is needed, it should be destroyed and recreated.
    but yet, since it is being resized to nothing, perhaps not.

    I don't think his problem was that it appears in the taskbar, but that he had to click on it in order to press a key to end the program. With your solution the second window pops up to await the key press.

    Leave a comment:


  • Manuel Valdes
    replied
    Not a cure, but a workaround:

    I guess the first GW is used to meassure the size of some Fonts and Texts, so as to open the second GW with a pre-determined size.

    The workaround is to use a Bitmap instead. A Bitmap is not visible, but can be used to do the same. This way the single GW gets the focus as soon as it's attached.

    Regards,

    Leave a comment:


  • Dave Biggs
    replied
    ..The only drawback is that a taskbar icon appears for hGW1 (for a short time ...).
    GRAPHIC WINDOW "", 0, 0, 0, 0 TO hGW1 '(No caption - no titlebar) Will fix that

    Leave a comment:


  • Rodney Hicks
    replied
    Move GRAPHIC DETACH so it follows the GRAPHIC WINDOW END.
    This closes the first, before creating the second.
    Code:
    'Focus problem for second GW
    'Compilers: PB/CC 5.01and PB/Win 9.01
    'OS: Win XP SP2
    
    #COMPILE EXE
    #DIM ALL
    #IF %DEF(%PB_CC32)
        #BREAK ON
        #CONSOLE OFF
    #ENDIF
    
    #INCLUDE "Win32Api.Inc"
    
    '----------------------------------------------------------------------------------------------
    
    FUNCTION PBMAIN
        LOCAL hGW1, hGW2   AS DWORD
    
        GRAPHIC WINDOW "Test_focus: Green", 300, 300, 300, 100 TO hGW1
        GRAPHIC ATTACH hGW1, 0
        GRAPHIC CLEAR %GREEN
        GRAPHIC PRINT " Press any key ..."
        GRAPHIC WAITKEY$        '<-- Take this line out and hGW2 does not get the focus any more
        GRAPHIC WINDOW END
        GRAPHIC DETACH
    
        GRAPHIC WINDOW "Test_focus: Red", 400, 400, 300, 100 TO hGW2
        GRAPHIC ATTACH hGW2, 0
        GRAPHIC CLEAR %RED
        GRAPHIC SET FOCUS       '<--  Neither this works,
        'nor OpenIcon(), ShowWindow(), SetActiveWindow(), SetForegroundWindow(), SetWindowPos() ,....?
        GRAPHIC PRINT " Press any key ..."
        GRAPHIC WAITKEY$
        GRAPHIC WINDOW END
    
    END FUNCTION
    
    '----------------------------------------------------------------------------

    Leave a comment:


  • Gert Voland
    replied
    Rodney,

    Thanks - yes, a DETACH leaves the following WINDOW END without a target. Thus, the END is not effective.

    Currently I work around it like this:
    Place the first WINDOW END after creating hGW2. Until then one could minimize hGW1 (or make it very small; e.g. 0x0 pixels).
    I need the first GW to measure text size with varying fonts. The only drawback is that a taskbar icon appears for hGW1 (for a short time ...).
    This works, but is definitely no good windows management!

    I am still puzzled.

    Rgds, Gert.

    Leave a comment:


  • Rodney Hicks
    replied
    Try putting GRAPHIC DETACH before GRAPHIC WINDOW END
    Both graphic windows then show up and disappear with the single touch of a key. Probably not what you want either.

    Leave a comment:


  • Gert Voland
    started a topic Any cure for this ...?

    Any cure for this ...?

    I came across this very unfortunate effect:

    When a program with a GRAPHIC WINDOW does not need the focus for input by keyboard or mouse - and the GW gets closed -
    a second GW will stay iconized and will be waiting for the user to click it back onto the screen.
    In this state the taskbar icon starts blinking or becomes orange.
    The program behaves extremely stubborn then. It does not react to any command to change the focus or appearance.

    PB support has been helpful in explaining but does not have any solution.

    I find it very irritating that MS requests the user to interact physically before a program can continue.
    Normally, there seems to be an API call for everything and anything else!

    Can someone point us to a description of this iconized blinking state?
    Is there possibly a programmatic way out of this state?

    Rgds,
    Gert Voland.


    Here is some sample code. REM out the first GRAPHIC WAITKEY$ and you are stuck!
    Code:
    'Focus problem for second GW
    'Compilers: PB/CC 5.01and PB/Win 9.01
    'OS: Win XP SP2
    
    #COMPILE EXE
    #DIM ALL
    #IF %DEF(%PB_CC32)
        #BREAK ON
        #CONSOLE OFF
    #ENDIF
    
    #INCLUDE "Win32Api.Inc"
    
    '----------------------------------------------------------------------------------------------
    
    FUNCTION PBMAIN
        LOCAL hGW1, hGW2   AS DWORD
    
        GRAPHIC WINDOW "Test_focus: Green", 300, 300, 300, 100 TO hGW1
        GRAPHIC ATTACH hGW1, 0
        GRAPHIC CLEAR %GREEN
        GRAPHIC PRINT " Press any key ..."
        GRAPHIC WAITKEY$        '<-- Take this line out and hGW2 does not get the focus any more
        GRAPHIC WINDOW END
    
    
        GRAPHIC WINDOW "Test_focus: Red", 400, 400, 300, 100 TO hGW2
        GRAPHIC ATTACH hGW2, 0
        GRAPHIC CLEAR %RED
        GRAPHIC SET FOCUS       '<--  Neither this works,
        'nor OpenIcon(), ShowWindow(), SetActiveWindow(), SetForegroundWindow(), SetWindowPos() ,....?
        GRAPHIC PRINT " Press any key ..."
        GRAPHIC WAITKEY$
        GRAPHIC WINDOW END
    
    END FUNCTION
    
    '----------------------------------------------------------------------------
Working...
X