Board index » delphi » GetWindow(hwindow,gw_....); RES file definition

GetWindow(hwindow,gw_....); RES file definition

Comp.Lang.Pascal and in Comp.Lang.Pascal.Borland
=-=-=-=-=-=-=-=-=-=-=-=--==-=-=-=-=-=-=-=-=-=-=-=--=
Hi!

I've got a small programming "problem"...  

What I'm trying to accomplish is to build a "TellTale" window which
would popup the moment I minimize my main window. This "TellTale" would
then show the status of a currently running process.

My main window is of TDLGWindow and I've defined a child "TellTale"
window of TWindow type.

I have the following TellTale Window definition:

  (* TTellTaleWnd is a TellTale window shown when minimized *)
  PTellTaleWnd = ^TTellTaleWnd;
  TTellTaleWnd = Object(TWindow)
    BBSName: TBBSName;
    Constructor Init(AParent: PWindowsObject; AName: PChar);
    Procedure SetupWindow;
      Virtual;
  end;

I create it in the following method:
(TMainDlg has a field of type PTellTaleWnd in its Object definition).

Procedure TMainDlg.SetupWindow;
Var
 Msg: TMessage;
 MyHWnd: HWnd;
Begin
 TDlgWindow.SetupWindow;
 (* Snip *)

 TellTaleWnd:= New(PTellTaleWnd,Init(@Self,'TellTale'));
 Application^.MakeWindow(TellTaleWnd);
End;

Question 1: How do I retrieve the Window Handle of this newly created
Window?  I've tried the: myHWnd:= GetWindow(hwindow,gw_....); but this
doesn't give me the correct handle. I've also tried the FindWindow but
somehow the window couldn't be located... I think I need this handle to
be able to send messages to this Window object.

Question 2: How come this setup doesn't use the TellTale definition from
my .RES file? Defined as follows:

TELLTALE DIALOG 18, 18, 70, 31
STYLE DS_MODALFRAME | WS_CHILD | WS_BORDER
CAPTION "TellTale"
BEGIN
 CONTROL "This is my TellTale", -1, "STATIC", SS_LEFT | WS_CHILD |
 WS_VISIBLE | WS_GROUP, 4, 13, 71, 8
END

Right now I've (custom) implemented the TellTale in the
TTellTale.SetupWindow by setting the various Attr. attributes.
But I want this Window to be created using the .RES file just like the
other "dialogs" in this program.

I want my TellTale to become visible when I minimize the "Main Window"
by using (more or less) the following code:

Procedure TMainDlg.wmSysCommand(Var Msg: TMessage);
Begin
 Case Msg.WParam of
   sc_Minimize:
     begin
      ShowTellTale;
     end;
   sc_Restore, sc_Maximize:
     begin
      HideTellTale;
     end;
 end;
 DefWndProc(Msg);
End;

In the Hide/ShowTellTale I intend to send a message to the TellTale to
show/hide it:  { ShowWindow(hWindow,SW_MINIMIZE); } etc. At this moment,
however, when I minimize the Main window the TellTale also gets
minimized. Question 3: Is this a possible setup?

Another problem I'm having is getting accelerator keys to work,
eg. F1 = Help.
Like said my main Window is of type TDlgWindow.
I load the Accelerators in the folowing procedure:

Procedure TPhoneCostApp.InitInstance;
Begin
 TApplication.InitInstance;
 hAccTable:= LoadAccelerators(hInstance,'Accelerators');
End;

This results in a valid hAccTable handle but the defined keys simply
don't fire of the derired "functions"....

And the last problem I face is that I can't get my App to start
minimized based on a setting in an .ini file.

I tried :
Procedure TMainDlg.SetupWindow;
Var
 Msg: TMessage;
 MyHWnd: HWnd;
Begin
 TDlgWindow.SetupWindow;
 (* Snip *)
 if StartMinimized = True
   then ShowWindow(hWindow,SW_MINIMIZE);
End;

The Icon flickers very shortly and then the Main TDlgWindow comes up. Is
it maybe that what I want here just isn't possible with a "main Window"
of TDlgWindow type?

I'm developing all this in Borland Pascal for Windows using the OWL
library.

PLEASE, PLEASE Reply to me privately (LPosth...@pobox.qstone.nl) as I'm
not in the position to check the UseNet archives regularly.

Thank you all for your help!

Lars
(LPosth...@pobox.qstone.nl)
posted by Harold on behalf of Lars...

 

Re:GetWindow(hwindow,gw_....); RES file definition


In article <harold_schellekens.11.00178...@mindlink.net>,
harold_schellek...@mindlink.net (Harold Schellekens) says:

Quote

>Comp.Lang.Pascal and in Comp.Lang.Pascal.Borland
>=-=-=-=-=-=-=-=-=-=-=-=--==-=-=-=-=-=-=-=-=-=-=-=--=
>Hi!

Hallo

Quote
>I've got a small programming "problem"...  
>What I'm trying to accomplish is to build a "TellTale" window which
>would popup the moment I minimize my main window. This "TellTale" would
>then show the status of a currently running process.

>My main window is of TDLGWindow and I've defined a child "TellTale"
>window of TWindow type.

>I have the following TellTale Window definition:

>  (* TTellTaleWnd is a TellTale window shown when minimized *)
>  PTellTaleWnd = ^TTellTaleWnd;
>  TTellTaleWnd = Object(TWindow)
>    BBSName: TBBSName;
>    Constructor Init(AParent: PWindowsObject; AName: PChar);
>    Procedure SetupWindow;
>      Virtual;
>  end;

>I create it in the following method:
>(TMainDlg has a field of type PTellTaleWnd in its Object definition).

>Procedure TMainDlg.SetupWindow;
>Var
> Msg: TMessage;
> MyHWnd: HWnd;
>Begin
> TDlgWindow.SetupWindow;
> (* Snip *)

> TellTaleWnd:= New(PTellTaleWnd,Init(@Self,'TellTale'));
> Application^.MakeWindow(TellTaleWnd);
>End;

>Question 1: How do I retrieve the Window Handle of this newly created
>Window?  I've tried the: myHWnd:= GetWindow(hwindow,gw_....); but this
>doesn't give me the correct handle. I've also tried the FindWindow but
>somehow the window couldn't be located... I think I need this handle to
>be able to send messages to this Window object.

The window handle (AFTER MakeWindow) is TellTaleWnd^.hWindow.

Quote
>Question 2: How come this setup doesn't use the TellTale definition from
>my .RES file? Defined as follows:

>TELLTALE DIALOG 18, 18, 70, 31
>STYLE DS_MODALFRAME | WS_CHILD | WS_BORDER
>CAPTION "TellTale"
>BEGIN
> CONTROL "This is my TellTale", -1, "STATIC", SS_LEFT | WS_CHILD |
> WS_VISIBLE | WS_GROUP, 4, 13, 71, 8
>END

>Right now I've (custom) implemented the TellTale in the
>TTellTale.SetupWindow by setting the various Attr. attributes.
>But I want this Window to be created using the .RES file just like the
>other "dialogs" in this program.

I believe you shouldn't use Application^.MakeWindow, but something else.
(forgot which, lookup an DlgWindow example)

- Show quoted text -

Quote
>I want my TellTale to become visible when I minimize the "Main Window"
>by using (more or less) the following code:

>Procedure TMainDlg.wmSysCommand(Var Msg: TMessage);
>Begin
> Case Msg.WParam of
>   sc_Minimize:
>     begin
>      ShowTellTale;
>     end;
>   sc_Restore, sc_Maximize:
>     begin
>      HideTellTale;
>     end;
> end;
> DefWndProc(Msg);
>End;

>In the Hide/ShowTellTale I intend to send a message to the TellTale to
>show/hide it:  { ShowWindow(hWindow,SW_MINIMIZE); } etc. At this moment,

SW_HIDE does hide it. SW_MINIMIZE minimizes it.

Quote
>however, when I minimize the Main window the TellTale also gets
>minimized. Question 3: Is this a possible setup?

I would be annoyed, that, whenever I to minimize something,
I get another window in return.
Apart from that, zero the four least significant bits of wParam.

Quote
>Another problem I'm having is getting accelerator keys to work,
>eg. F1 = Help.
>Like said my main Window is of type TDlgWindow.

Accelerators don't work when a dialog is active. You can get it
to work by changing the processing order of TApplication.
(It's in a method, change the order so Accelerators are handled
before dialog messages).
Warning: This could result in always working accelerators, even
when messageboxes etc. are displayed.

- Show quoted text -

Quote
>I load the Accelerators in the folowing procedure:

>Procedure TPhoneCostApp.InitInstance;
>Begin
> TApplication.InitInstance;
> hAccTable:= LoadAccelerators(hInstance,'Accelerators');
>End;

>This results in a valid hAccTable handle but the defined keys simply
>don't fire of the derired "functions"....

>And the last problem I face is that I can't get my App to start
>minimized based on a setting in an .ini file.

>I tried :
>Procedure TMainDlg.SetupWindow;
>Var
> Msg: TMessage;
> MyHWnd: HWnd;
>Begin
> TDlgWindow.SetupWindow;
> (* Snip *)
> if StartMinimized = True
>   then ShowWindow(hWindow,SW_MINIMIZE);
>End;

Change to:
  if StartMinimized then ShowCmd := SW_MINIMIZE

Quote
>The Icon flickers very shortly and then the Main TDlgWindow comes up. Is
>it maybe that what I want here just isn't possible with a "main Window"
>of TDlgWindow type?

No, OWL 'features' a global. Change it's value as you like.
The original value is the value that the user wants you to start -
it's the value that you setup in the Program Manager (the little
'Run minimized' checkbox)

Quote

>I'm developing all this in Borland Pascal for Windows using the OWL
>library.

>PLEASE, PLEASE Reply to me privately (LPosth...@pobox.qstone.nl) as I'm
>not in the position to check the UseNet archives regularly.

>Thank you all for your help!

>Lars
>(LPosth...@pobox.qstone.nl)
>posted by Harold on behalf of Lars...

-----------------------------------------------------------------------
  Zweitze de Vries                           zwei...@cyco.nl
  Cyco Software Development
  Handelskade 49
  Rijswijk, Netherlands                      (+31) 70 3954179

Re:GetWindow(hwindow,gw_....); RES file definition


I believe part of your problem is you declared the
TTellTaleWnd as an object of TWINDOW, but should be
an object of TDLGWINDOW.

Using TWINDOW sets the window title to 'TellTale' rather than
loading the resource dialog 'TellTale'.

That's one problem I can see.

Personal recommendation is not to use a dlgwindow to begin with.

Be better to use a TWINDOW class, and put a timer routine in for
showwindow, and peekmessage(). would be alot less confusing, and
easier to get it working.

If you stick with the dlgwindow, make sure you don't have the options
for the dialog set to system modal either.

About all I can tell you with the information given.

Hope it helps.
--
------------------------------------------------------
Jeffrey L. Meyer, Owner-MeySoft    jmey...@meysoft.com
http://www.meysoft.com
------------------------------------------------------

Other Threads