Page 1 of 1

Dlg2Wnd

Posted: Mon Apr 11, 2022 8:03 pm
by Detlef
Hi dear friends,

I searched this forum without success- so I ask you if anyone knows a tool or procedure to transform a dialog into a window?
My dialog is designed with rc-editor of Pelles C because this way it's easy to place all my controls.
But I want a window as start screen.

I'll be glad for each hint.
-Detlef

Re: Dlg2Wnd

Posted: Mon Apr 11, 2022 10:29 pm
by cmsoft
Detlef:
A good starting point would be to look at the xbrowser function which uses a resizable dialog

Re: Dlg2Wnd

Posted: Tue Apr 12, 2022 9:30 am
by Antonio Linares
Detlef,

If you use the style WS_THICKFRAME in your dialog then you will be able to resize it

Re: Dlg2Wnd

Posted: Tue Apr 12, 2022 9:45 am
by nageswaragunupudi

Code: Select all | Expand

DEFINE DIALOG oDlg RESIZABLE
 

Re: Dlg2Wnd

Posted: Tue Apr 12, 2022 3:59 pm
by Detlef
Many thanks for all your help.
Unfortunately I did explain my concern very bad.
It was not the resizing that I wanted.

My program should start showing a window with buttonbar, three browses, a memo edit and some normal buttons.
I found it very annoying to place all those objects by trying to find exact values for @ y, x . . . to align all my objects.
So I created a Dialog with Pelles rc-editor and was able to place all my controls visually much more comfortable.
Now I'm looking for a way to covert this dialog to a window object.

May be I will write a codeblock for right clicks of my components to display the exact coordinates.
Those values I could use to design a window looking equal to that dialog.

-Detlef

Re: Dlg2Wnd

Posted: Tue Apr 12, 2022 4:41 pm
by Antonio Linares
Dear Detlef,

Here you have an example you can use in your apps:

Code: Select all | Expand

#include "FiveWin.ch"

#define GW_CHILD        5
#define GW_HWNDNEXT     2

function Main()

   local oWnd

   DEFINE WINDOW oWnd

   ACTIVATE WINDOW oWnd ON INIT GetControls( oWnd, "MyDialog" )

return nil

function GetControls( oWnd, cResName )

   local oDlg

   DEFINE DIALOG oDlg RESOURCE cResName

   ACTIVATE DIALOG oDlg ON INIT ( MoveControls( oDlg, oWnd ), oDlg:End() )

return nil

function MoveControls( oDlg, oWnd )

   local hCtrl := GetWindow( oDlg:hWnd, GW_CHILD ), hCtrlNext

   while hCtrl != 0 .and. GetParent( hCtrl ) == oDlg:hWnd
      hCtrlNext = GetWindow( hCtrl, GW_HWNDNEXT )
      SetParent( hCtrl, oWnd:hWnd )
      hCtrl = hCtrlNext
   end
   
   oWnd:aControls = oDlg:aControls
   AEval( oWnd:aControls, { | oCtrl | oCtrl:oWnd := oWnd } )

return nil  

Re: Dlg2Wnd

Posted: Tue Apr 12, 2022 5:13 pm
by Detlef
Dear Antonio,

thanks for your advice. I tried your code but it gives me an Error FiveWin/3 Cannot create Dialog Box: Resource: START

Code: Select all | Expand

Stack Calls
===========
   Called from: .\source\classes\DIALOG.PRG => CREATEDLGERROR( 717 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 306 )
   Called from: svp.prg => GETCONTROLS( 295 )
   Called from: svp.prg => (b)MAIN( 40 )
   Called from: .\source\classes\WINDOW.PRG => TWINDOW:ACTIVATE( 1083 )
   Called from: svp.prg => MAIN( 40 )


Now I do configure my start window by "try 'n error" with @ y, n ...
And take it as a training for design :-)

-Detlef

Re: Dlg2Wnd

Posted: Tue Apr 12, 2022 5:20 pm
by Antonio Linares
Detlef,

For the above example you have to use this RC:

Code: Select all | Expand

#include "windows.h"

MyDialog DIALOG 32, 18, 236, 118
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "DIALOG"
FONT 6, "MS San Serif"
BEGIN
   RTEXT "Name"      , -1, 3,   5, 41, 8
   RTEXT "Level"     , -1, 3,  61, 41, 8
   EDITTEXT 10, 45,  59,   12, 12
   RTEXT "Date"      , -1, 3,  75, 41, 8
   EDITTEXT 20, 45,  73,   36, 12
   RTEXT "Notes"     , -1, 100,  89, 41, 8
END
 

Re: Dlg2Wnd

Posted: Tue Apr 12, 2022 6:40 pm
by Detlef
Dear Antonio,

now your example works fine.
I'll try to use it for my app.
Sorry for troubling you.

-Detlef

Re: Dlg2Wnd

Posted: Tue Apr 12, 2022 7:38 pm
by Antonio Linares
You have to REDEFINE your controls in the dialog creation as usual

Re: Dlg2Wnd

Posted: Tue Apr 12, 2022 7:57 pm
by Marc Venken
Detlef,

You may also consider of using a Xbrowse as setup Dialog/Window designer.

All coordinates can be filled/change at runtime and this way the recompile of prg etc.. is not needed.

Button, Position, action, visuals, can be in the Xbrowse and in the program a loop while create the dialog.

Re: Dlg2Wnd

Posted: Tue Apr 12, 2022 9:09 pm
by Detlef
Thanks, Marc.
I'll try this.

-Detlef