Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#2 Tab Windows Crashes Program

Current
open
David Botton
5
2004-10-20
2004-10-20
David Botton
No

Hullo. I could isolate the problem. It seems to have to do with the
tabs
being in a child window or dialog instead of a main window or
dialog.
I copy hereafter a little changed version of David's example on
which
clicking the buttons hang the application (with gwindows-20030401)
.
Again, maybe the mistake is mine (but which one ?...).
Gautier

with GWindows.Windows.Main; use GWindows.Windows.Main;
with GWindows.Windows; use GWindows.Windows;
with GWindows.Common_Controls; use
GWindows.Common_Controls;
with GWindows.Buttons; use GWindows.Buttons;
with GWindows.Base; use GWindows.Base;
with GWindows.Application;
with GWindows.Constants; use GWindows.Constants;

procedure Tab_Test2 is
Top_Window : Main_Window_Type;
Start_Panel : Button_Type;

procedure Panel_Dialog(Parent : in out
GWindows.Base.Base_Window_Type'Class) is
Panel : Window_Type;
Okay : Default_Button_Type;
Tab_Control : Tab_Window_Control_Type;
Window_1 : aliased Window_Type;
Window_2 : aliased Window_Type;
Result : Integer;

procedure Do_Click (Window : in out Base_Window_Type'Class)
is
begin
Text (Top_Window, Text(Window));
end Do_Click;

begin
Create_As_Dialog(Panel, Parent, "Panel");

Create (Tab_Control, Panel, 10, 10, 300, 150);

Insert_Tab (Tab_Control, 0, "Tab1");
Insert_Tab (Tab_Control, 1, "Tab2");

Create_As_Control (Window_1,
Tab_Control, "",
0, 0, 10, 10,
Show => False);
Create_As_Control (Window_2,
Tab_Control, "",
0, 0, 10, 10,
Show => False);

Tab_Window (Tab_Control, 0, Window_1'Unchecked_Access);
Tab_Window (Tab_Control, 1, Window_2'Unchecked_Access);

declare
Button_1 : Button_Access;
Button_2 : Button_Access;
begin
Button_1 := new Button_Type;
Create (Button_1.all, Window_1, "Button 1",
10, 30, 75, 25, Is_Dynamic => True);
On_Click_Handler (Button_1.all,
Do_Click'Unrestricted_Access);

Button_2 := new Button_Type;
Create (Button_2.all, Window_2, "Button 2",
10, 30, 75, 25, Is_Dynamic => True);
On_Click_Handler (Button_2.all,
Do_Click'Unrestricted_Access);
end;

Dock (Tab_Control, Fill);

Create (Okay, Panel, "O&k", 20,
Client_Area_Height (Panel) - 40, 60, 25, Id => Idok);

Dock_Children (Panel);

Result := GWindows.Application.Show_Dialog (Panel,
Top_Window);

end Panel_Dialog;

begin
Create (Top_Window, "Control Test");
Create (Start_Panel, Top_Window, "Start Panel",
10, 30, 125, 25, Is_Dynamic => True);
On_Click_Handler (Start_Panel,
Panel_Dialog'Unrestricted_Access);
Dock_Children (Top_Window);
Show (Top_Window);

GWindows.Application.Message_Loop;
end Tab_Test2;

Discussion

  • Logged In: YES
    user_id=1207581
    Originator: NO

    Solution by AvS (6-Jan-2007):
    After you created the Tab_Control, add the following line:

    SetWindowLong (Handle (Base_Window_Type (Tab_Control)), GWL_EXSTYLE,
    GetWindowLong (Handle (Base_Window_Type (Tab_Control))) +
    WS_EX_CONTROLPARENT);

    The discussion here is about how to integrate it properly into GWindows:
    http://sourceforge.net/mailarchive/message.php?msg_id=37837306