MDI-Child? 
Author Message
 MDI-Child?

Hello,

I have a problem:
I want to write a program, that uses a MDI-Child-Window, but I don't know
how to do that. All the demos I found are programmed using Object-orientated
Pascal. I don't like that (I always program without Objects).
Can anyone give me an example that shows how to create a MDI-Client Window
with MDI-Child-Windows?

Thanx in advance,
        Timo



Tue, 25 Mar 2003 03:00:00 GMT  
 MDI-Child?


Quote:
> Hello,

> I have a problem:
> I want to write a program, that uses a MDI-Child-Window, but I don't
know
> how to do that. All the demos I found are programmed using
Object-orientated
> Pascal. I don't like that (I always program without Objects).
> Can anyone give me an example that shows how to create a MDI-Client
Window
> with MDI-Child-Windows?

Below is straight windows pascal code ... no object code to do MDI
window.

Will work with BPW 1.5 or VirtualPascal.
If you know what you are doing can work with Delphi.

PROGRAM BASICMDI;

{&PMTYPE PM}                { Application is GUI NOT CONSOLE }

{$IFDEF VER100}             { Detects Delphi3 }
{$DEFINE WIN32}
{$ENDIF}

USES {$IFDEF WIN32} Windows; {$ELSE} WinTypes, WinProcs;{$ENDIF}

CONST wm_Destroy = $0002;

{$IFDEF WIN32}
TYPE Sw_Word = LongInt;
{$ELSE}
TYPE Sw_Word = Word;
{$ENDIF}

VAR Wnd: HWnd;

{ MESSAGE HANDLER }

FUNCTION GraphHandler (Wnd: hWnd; iMessage, wParam: Sw_Word;
lParam: LongInt): LongInt; {$IFDEF VirtualPascal} STDCALL; {$ENDIF}
EXPORT;
BEGIN
   GraphHandler := 0;                                 { Return zero }
   Case iMessage Of
     wm_Destroy: PostQuitMessage(0);                  { Post quit
message }
     Else GraphHandler := DefWindowProc(Wnd, iMessage,
       wParam, lParam);                               { Default
handler }
   End;
END;

CONST
   WindowType: LongInt = ws_ClipChildren OR ws_OverlappedWindow;
   ClassName: PChar = 'MYVIEW'+#0;

VAR Res: Boolean; S: String; H: Thandle; Msg: TMsg; Wnd1, Wnd2: HWnd;
WndClass: TWndClass;
BEGIN
   If NOT GetClassInfo(0, ClassName, WndClass)
   Then Begin                                         { Check if
registered }
     WndClass.Style := CS_HRedraw OR CS_VReDraw OR
       CS_DblClks;                                    { Class styles }

handler }
     WndClass.cbClsExtra := 0;                        { No extra
data }
     WndClass.cbWndExtra := 0;                        { No extra
data }
     WndClass.hInstance := HInstance;                 { Set instance }
     WndClass.hIcon := LoadIcon(0, Idi_Application);  { Set icon }
     WndClass.hCursor := LoadCursor(0, Idc_Arrow);    { Set cursor }
     WndClass.hbrBackground := GetStockObject(Gray_Brush);
     WndClass.lpszMenuName := Classname;              { No menu }
     WndClass.lpszClassName := ClassName;             { Set class
name }
     {$IFDEF WIN32}
     If (RegisterClass(WndClass) = 0) Then Begin
     {$ELSE}
     If (RegisterClass(WndClass) = False) Then Begin
     {$ENDIF}
       MessageBox(GetFocus, 'Can not Register Class',
         'UnKnown Error Cause?', mb_OK);              { Failed to
register }
       Halt;                                          { Halt on
failure }
     End;
   End;

   { Create main window }
   Wnd := CreateWindowEx(ws_Ex_DlgModalFrame, ClassName, 'BASIC',
WindowType,
     0, 0, 300, 300, 0, 0, hInstance, Nil);           { Create a
window }
   If (Wnd <> 0) Then Begin
     ShowWindow(Wnd, sw_ShowNormal);                  { Show window }
     UpdateWindow(Wnd);
   End;

   { Create item in window }
   Wnd1 := CreateWindowEx(0, ClassName, 'MDI_CHILD', ws_Child OR
ws_Visible or ws_OverlappedWindow,
     10, 10, 200, 100, Wnd, 1000,  hInstance, Nil);
   If (Wnd1 <> 0) Then Begin
     ShowWindow(Wnd1, sw_ShowNormal);                  { Show window }
   End;

   { Standard handler }
   Repeat
     Res := GetMessage(Msg, 0, 0, 0);
     TranslateMessage(Msg);
     DispatchMessage(Msg);
   Until (Res=False);

   DestroyWindow(Wnd);                                { Destroy the
window }
   UnregisterClass(ClassName, HInstance);             { Release
class }
END.

Regards Leon



Wed, 26 Mar 2003 11:32:47 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. MDI child from MDI child

2. How can MDI child forms have child forms ?

3. Formsize of MDI children

4. Mdi child looses focus

5. Cannot update data in a MDI child

6. ???MDI Child Windows???

7. TPW1.5 MDI Children

8. Maximized MDI child windows - close/system buttons vanishes in thin air

9. How to close an MDI-Child by itself?

10. MDI child close icon - problem

11. * Displaying Transparent MDI Child Forms *

12. Independent view on every MDI child form - problem

 

 
Powered by phpBB® Forum Software