BtnBmp on Main Window

BtnBmp on Main Window

Postby Colin Haig » Mon Dec 06, 2010 8:49 am

I have placed a BtnBmp control on the main window of my application but the
action clause does not work

Code: Select all  Expand view


         DEFINE WINDOW oMainWnd    ;
                MENU MainMenu(cPath,lClose) ;
                TITLE eval(cTitle) ;
                COLOR('N/W*') ;
                MDI


         
         SET MESSAGE OF oMainWnd TO FWVERSION + "  TechData Software " ;
         CENTERED 2007


         @ 220, 100 BTNBMP oBtn of oMainWnd ;
                size 100,70 ;
                prompt 'Button' 2007;
                action(MsgInfo('here'))

 


Is it because it is an MDI frame

Thanks

Colin
Colin Haig
 
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Re: BtnBmp on Main Window

Postby ukoenig » Mon Dec 06, 2010 12:37 pm

Hello Colin,

I think it is not possible, to paint Buttons directly on a Main-Window ( MDI-frame )
Found a possible Solution to paint one or more Buttons.
Transparent, Color, Gradient, Brush and Image :

Image

Code: Select all  Expand view

...
...
DEFINE BRUSH oBrush COLOR 14853684

DEFINE WINDOW oWndMain FROM 1, 1 TO 20, 70 TITLE "I am the MDI Frame" MDI BRUSH oBrush

DEFINE WINDOW oWndEdit MDICHILD OF oWndMain FROM 10, 40 TO 30, 80 ;
TITLE "I am a MDI Child" COLOR "W+/R"
 
ACTIVATE WINDOW oWndEdit
   
SET MESSAGE OF oWndEdit TO FWVERSION + "  TechData Software " ;
CENTERED 2007

ACTIVATE WINDOW oWndMain MAXIMIZED ;
ON INIT SHOW_BTN(oWndMain, oBrush)

SET MESSAGE OF oWndMain TO FWVERSION + "  TechData Software " ;
CENTERED 2007

oBrush:End()
oFont:End()  

RETURN oWnd
 
// -------- We need a Frame, to paint the Buttons ------------  

FUNCTION SHOW_BTN(oWndMain, oBrush)
LOCAL oDlg1, oBtn1, oBtn2, oBtn3

DEFINE DIALOG oDlg1 FROM 20, 20 TO 40, 40 OF oWndMain PIXEL BRUSH oBrush ;
STYLE nOr(WS_POPUP, WS_VISIBLE)

@ 0, 0 BTNBMP oBtn1 OF oDlg1 ;
SIZE 60 , 40  PROMPT "Button 1" 2007 ;
FONT oFont1 ;
TOP ;
NOBORDER ;
FILENAME ".\bitmaps\32x32\edit.bmp" ;
ACTION ( MsgInfo('here') )      

oBtn1:cTooltip :=  { "Show Button 1" + CRLF + ;
     "on Main-Window","Button 1", 1, CLR_BLACK, 14089979 }

@ 60, 0 BTNBMP oBtn2 OF oDlg1 ;
SIZE 60 , 40  PROMPT "Button 2" 2007 ;
FONT oFont1 ;
TOP ;
NOBORDER ;
FILENAME ".\bitmaps\32x32\fax.bmp" ;
ACTION ( MsgInfo('here') )      

oBtn2:cTooltip :=  { "Show Button 2" + CRLF + ;
     "on Main-Window","Button 2", 1, CLR_BLACK, 14089979 }

@ 120, 0 BTNBMP oBtn3 OF oDlg1 ;
SIZE 60 , 40  PROMPT "Button 3" 2007 ;
FONT oFont1 ;
TOP ;
NOBORDER ;
FILENAME ".\bitmaps\32x32\magic.bmp" ;
ACTION ( MsgInfo('here') )      

oBtn3:cTooltip :=  { "Show Button 3" + CRLF + ;
     "on Main-Window","Button 3", 1, CLR_BLACK, 14089979 }

ACTIVATE DIALOG oDlg1 NOWAIT ;
ON INIT oDlg1:Move( 80, 100, 120, 380, .f.)

RETURN NIL
 


Image

Image

Image

We can use Images as well

Image

Best Regards
Uwe :lol:
Last edited by ukoenig on Mon Dec 06, 2010 7:21 pm, edited 3 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: BtnBmp on Main Window

Postby James Bott » Mon Dec 06, 2010 4:43 pm

Collin and Uwe,

There is no need to use a PUBLIC or to pass the main window object to another function. This object is stored in the function wndMain() so you can access it anywhere in your program. You can also access it using a kind of shorthand syntax:

Instead of:

local oWnd
oWnd:= wndMain()
oWnd:setColor(...)

You can simply do:

wndMain():setColor(...)

Another example:

define dialog oDlg ... of wndMain()


Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: BtnBmp on Main Window

Postby Colin Haig » Mon Dec 06, 2010 11:49 pm

Uwe and James

Thanks for your replies

I got the button to work but being a nonmodal dialog it was visible over child windows.

Code: Select all  Expand view

          DEFINE DIALOG oDlg1 FROM 20, 20 TO 40, 40 OF oMainWnd PIXEL  ;
                 STYLE nOr(WS_POPUP, WS_VISIBLE)


           @ 1,1 BTNBMP oBtn of oDlg1;
                size 50,20 ;
                prompt 'Button' 2007;
                action(oDlg1:Hide(),fnods(oMainWnd,cPath),oDlg1:Show())

                ACTIVATE DIALOG oDlg1 NOWAIT;
                ON INIT oDlg1:Move( 80, 100, 120, 380, .f.)

 


Cheers

Colin
Colin Haig
 
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Re: BtnBmp on Main Window

Postby James Bott » Tue Dec 07, 2010 12:37 am

Colin,

It seems complicated but you could try hiding the dialog when a child window is opened, and showing it when the window is closed.

This is one more reason I never use MDI.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: BtnBmp on Main Window

Postby Colin Haig » Tue Dec 07, 2010 1:11 am

Hi James

Yes it does seem complicated - I changed the way the menu calls options - this
may give the client what he wants.

Cheers

Colin
Colin Haig
 
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Re: BtnBmp on Main Window

Postby ukoenig » Tue Dec 07, 2010 1:30 am

Colin,

I agree with James,
I did a quick test with 2 embedded Dialogs and Nowait.
It works fine with the same Result like 2 Windows ( MDI )
Moving the Dialog, it covers the Dialog with the Buttons.
Is there maybe a special reason, You need MDI ?
I will create a new sample tomorrow. Maybe it works for You.
Showing Buttons inside a Dialog with no Border, no Sysmenu, no Title,
is a nice Solution, to create a Buttonbar on any Screen-position.
With a normal Buttonbar, You have fixed Positions ( TOP, LEFT, RIGHT, BOTTOM, FLOAT ).

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: BtnBmp on Main Window

Postby Colin Haig » Tue Dec 07, 2010 2:51 am

Hi Uwe

I like MDI apps and so do my clients they quite often have the same screen
open twice with different data selected.

I must admit the visuals you create are amazing.

Cheers

Colin
Colin Haig
 
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Re: BtnBmp on Main Window

Postby James Bott » Tue Dec 07, 2010 3:11 am

Colin,

>I like MDI apps and so do my clients they quite often have the same screen
open twice with different data selected.

You can do this with a main window and a splitter too.

Just about anything you can do with MDI you can do with SDI.

The main issue I have with MDI is all the window manipulation that the user has to do. This is just overhead work for them, that gets in the way of what they are trying to do.

IMHO.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: BtnBmp on Main Window

Postby Daniel Garcia-Gil » Tue Dec 07, 2010 6:22 am

Colin

if you want work over MDI main window you should use DATA oWndClient

like this

Code: Select all  Expand view
#include "fivewin.ch"

function main()

   local oMainWnd, oBtn

   DEFINE WINDOW oMainWnd    ;
          TITLE "testing" ;
          COLOR('N/W*') ;
          MDI
   
   SET MESSAGE OF oMainWnd TO FWVERSION + "  TechData Software " ;
   CENTERED 2007


   @ 220, 100 BTNBMP oBtn of oMainWnd:oWndClient ;
          size 100,70 ;
          prompt 'Button' 2007;
          action(MsgInfo('here'))
               
    ACTIVATE WINDOW oMainWnd
   
return nil
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: BtnBmp on Main Window

Postby Colin Haig » Tue Dec 07, 2010 10:08 am

Hi Daniel

Tht works fine except when you open a window over the button and then close the window the button does not
show until you mouse over it - is there a way to refresh the main window and button.

Cheers

Colin
Colin Haig
 
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Re: BtnBmp on Main Window

Postby James Bott » Tue Dec 07, 2010 3:03 pm

Colin,

Maybe try:

oMainWnd:bGotFocus:= {|| oBtn:refresh() }

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: BtnBmp on Main Window

Postby Colin Haig » Tue Dec 07, 2010 9:37 pm

Hi James

Yes I tried that - but the oMainwWnd:bGotFocus does not seem to work except for
the first time the main window is displayed.

The only way I could find for the button to display was to mouse over it.

Cheers

Colin
Colin Haig
 
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Re: BtnBmp on Main Window

Postby ukoenig » Tue Dec 07, 2010 11:01 pm

Colin,

I added some more Functions to my Sample.
All Buttons are working fine now ( changed from Dialog to MDI-child ).
I hope, it will work for You :roll:

Image

You can create a extra Child, only for the Buttons.
( I can use the same Background like the Main-window to make it transparent looking )
It works exactly like I have done before with the Dialog, but now the Main-Child is on Top like expected
and covers the Buttons.

For the Screenshot-sample the Button-part ( Color-Background ) :
..
..
DEFINE BRUSH oBrush3 COLOR 14853684

DEFINE WINDOW oWndBtn MDICHILD OF oWndMain FROM 50, 50 TO 350, 220 PIXEL ;
BORDER NONE ;
NOSYSMENU ;
NOICONIZE ;
NOCAPTION ;
BRUSH oBrush3


@ 10, 10 BTNBMP oBtn1 OF oWndBtn PIXEL ;
SIZE 150 , 80 PROMPT "Hide Child" 2007 ;
FONT oFont1 ;
TOP ;
NOBORDER ;
FILENAME ".\bitmaps\32x32\Hide.bmp" ;
ACTION ( oWndEdit:Hide() )
oBtn1:SetColor( 128, )
oBtn1:cTooltip := { "Show Button 1" + CRLF + ;
"on Main-Window","Button 1", 1, CLR_BLACK, 14089979 }

@ 110, 10 BTNBMP oBtn2 OF oWndBtn PIXEL ;
SIZE 150 , 80 PROMPT "Show Child" 2007 ;
FONT oFont1 ;
TOP ;
NOBORDER ;
FILENAME ".\bitmaps\32x32\Show.bmp" ;
ACTION ( oWndEdit:Show() )
oBtn2:SetColor( 128, )
oBtn2:cTooltip := { "Show Button 2" + CRLF + ;
"on Main-Window","Button 2", 1, CLR_BLACK, 14089979 }

@ 210, 10 BTNBMP oBtn3 OF oWndBtn PIXEL ;
SIZE 150 , 80 PROMPT "Exit" 2007 ;
FONT oFont1 ;
TOP ;
NOBORDER ;
FILENAME ".\bitmaps\32x32\Exit.bmp" ;
ACTION ( oWndMain:End() )
oBtn3:SetColor( 128, )
oBtn3:cTooltip := { "Show Button 3" + CRLF + ;
"on Main-Window","Button 3", 1, CLR_BLACK, 14089979 }


ACTIVATE WINDOW oWndBtn
...
...

Because it is not possible, to create a TRANSPARENT Child-window,
that will show the Background from WndMain, it gets more tricky.

Image

1. we have to make a Screencapture from the covered Wndmain-area.
2. we use this Capture ( Section ) as Brush

Sample with captured Background-section :

only needed if using Gradient or Image as WndMain-background !!!

DEFINE BRUSH oBrush3 FILENAME cImage3A // Screencapture-section
DEFINE WINDOW oWndBtn MDICHILD OF oWndMain FROM 50, 50 TO 350, 220 PIXEL ;
BORDER NONE ;
NOSYSMENU ;
NOICONIZE ;
NOCAPTION ;
BRUSH oBrush3

with Image-Background :

Image

Captured-area defined as Child-background :

Image

Image

Image

Best Regards
Uwe :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 93 guests