May 22, 2024, 12:07:58 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Child window without caption

Started by Bruce Peaslee, December 21, 2005, 03:38:46 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bruce Peaslee

I want to put a bunch of child windows in a MDI frame, but I want to have them look just like a square: no caption, no close box, etc. IB had a @NOCAPTION constant you could add to the openwindow function. How do I do the same thing here?
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Zen

In Aurora it is different. You have to declare all the styles you want and the ones you leave out dont get used. So basicly if you dont specify AWS_CPATION then you dont get the caption.

Lewis

Zen

Oh sorry that wont work. In an MDI window the child windows act different. I did some work with removing the caption and everything in IBasic. Give me a moment to change over the code and ill post it for you.

Lewis

Zen

Ok here we go. I just modified the example MDI source code. This will remove the captions with ModifyStyle. However this only works on windows XP with visual styles enabled. So i have also add some code from the windows API to create a region on the window which does the same effect but works on all OS's


declare import,CreateRectRgn(int L,int T,int W,int H),unsigned int;
declare import,SetWindowRgn(unsigned int hWnd,unsigned int hRgn,int bRedraw),int;

class MyFrame : MDIFrameWnd {

declare MyFrame();
declare OnClose(),int;
declare OnCreate(),int;
declare AddChild();
pointer m_pChildren;
int m_nChildren;

}

class MyChild : MDIChildWnd {

declare MyChild();
declare OnClose(),int;
MyFrame *m_parent;

}

global sub main() {

MyFrame frame;

frame.Create(0,0,800,600,AWS_CAPTION|AWS_SYSMENU |AWS_BORDER|AWS_VISIBLE|AWS_SIZE|AWS_MAXIMIZEBOX,0,"Frame Window",NULL);

frame.AddChild();

do{

wait();

}until frame.m_hwnd = 0;

return 0;

}

MyFrame :: MyFrame() {

m_nChildren = 0;
m_pChildren = new(int,100);

return;

}

MyFrame :: OnClose() {

int x;
MyChild *pTemp;

For(x=0;x < m_nChildren;x++) {

pTemp = *(pointer)(m_pChildren + x*4);

if(pTemp <> NULL) {

delete pTemp;
}

}

delete m_pChildren;

Destroy();

return true;

}

MyFrame :: OnCreate() {

CenterWindow();

return true;

}

MyFrame :: AddChild() {

int x;
MyChild *pTemp;

for(x = 0;x<m_nChildren;x++) {

pTemp = *(pointer)(m_pChildren + x*4);

if((pTemp <> NULL) AND (pTemp->m_hWnd = NULL)) {

break;

}

}

if(x = m_nChildren) {

pTemp = new(MyChild,1);

*(pointer)(m_pChildren + x*4) = pTemp;

m_nChildren++;

}

pTemp->m_parent = this;

pTemp->Create(10,10,640,480,AWS_VISIBLE|AWS_CHILD|AWS_AUTODRAW,0,"Child:"+STR$(x+1,0),this);

/* Added To Remove Client Window Style */
/*  Only Works With XP Styles Though   */

pTemp->ModifyStyle(0,AWS_CAPTION|AWS_BORDER|AWS_SIZE);

SetWindowRgn(pTemp->m_hwnd,CreateRectRgn(0,0,600,480),1);

return;

}

MyChild :: MyChild() {

m_Parent = NULL;

return;

}

MyChild::OnClose() {

Destroy();

return true;

}


Hope this helps
Lewis

Bruce Peaslee

I'm not sure. Bedtime now - I'll experiment tomorrow.

Thanks.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Parker

Believe him. It works, I've seen it. ;)

Bruce Peaslee

Quote from: Parker on December 21, 2005, 11:13:34 PM
Believe him. It works, I've seen it. ;)
It works, I am just unclear as to why. I think I might have a clearer understanding if I move away from MDI/Child windows.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Parker

It sets the viewable region of the window to only the part that doesn't have a caption. Otherwise the caption would have junk all over it. Not something I would have thought of, but it's a cool solution.

Bruce Peaslee

OK.

I've backed up a bit to study classes and how they work. I'm still trying to get a window (any window this time) to appear in my main window. This tuns, but nothing shows up:


#AutoDefine "Off"

#typedef bool int;

// *****************************************************************************
// *ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  GLOBAL CONSTANTSÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, *
// *****************************************************************************

// Menu Constants (for program control)
const FILE_OPENÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, =ÂÃ,  1;
const FILE_CLOSEÂÃ,  ÂÃ,  ÂÃ,  =ÂÃ,  2;
const FILE_EXITÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, =ÂÃ,  3;
const EDIT_CUTÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  =ÂÃ,  4;
const EDIT_COPYÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, =ÂÃ,  5;
const EDIT_PASTEÂÃ,  ÂÃ,  ÂÃ,  =ÂÃ,  6;
const HELP_ABOUTÂÃ,  ÂÃ,  ÂÃ,  =ÂÃ,  7;
const HELP_HELPÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, =ÂÃ,  8;

// Menu Style Constants
const MF_ENABLEDÂÃ,  ÂÃ, = 0;
const MF_GRAYEDÂÃ,  ÂÃ,  = 1;
const MF_DISABLEDÂÃ,  = 2;
const MF_UNCHECKED = 0;
const MF_CHECKEDÂÃ,  ÂÃ, = 8;

// Window Style Constants
const WS_CHILDÂÃ,  ÂÃ, = 0x40000000;
const WS_VISIBLE = 0x10000000;

// Misc Constants
const GWL_HINSTANCEÂÃ,  ÂÃ,  = -6;
const BS_DEFPUSHBUTTON =ÂÃ,  1;
const WM_COMMANDÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, = 273;

// *****************************************************************************
// *ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  API DECLARATIONSÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, *
// *****************************************************************************

declare import, GetSysColor(index as int),int;
declare import, CreateWindowExA(
dwExStyle as unsigned INT,
lpClassNameÂÃ,  as string,
ÂÃ,  ÂÃ,  lpWindowName as string,
ÂÃ,  ÂÃ,  int dwStyle,
ÂÃ,  ÂÃ,  int x,
int y,
ÂÃ,  ÂÃ,  int nWidth,
ÂÃ,  ÂÃ,  int nHeight,
ÂÃ,  ÂÃ,  int hWndParent,
ÂÃ,  ÂÃ,  hMenu as unsigned int,
ÂÃ,  ÂÃ,  hInstance as unsigned int,
ÂÃ,  ÂÃ,  lpParam as pointer
),int;
declare import, GetModuleHandleA(int num),unsigned int;
declare import, SetWindowPos(
unsigned int hwnd,
unsigned int hwndinsertafter,
int x,
int y,
int cx,
int cy,
unsigned int uFlags
),INT;

// *****************************************************************************
// *ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  CLASSESÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  *
// *****************************************************************************

// -----------------------------------------------------------------------------
// mapWindow:Window
// -----------------------------------------------------------------------------
class mapWindow : window
{
declare OnCreate(), int;
}

mapWindow::OnCreate(),int
{
return true;
}

// -----------------------------------------------------------------------------
// myWindow:Window
// -----------------------------------------------------------------------------
class myWindow : window
{
// Overridden functions
declare OnClose(),ÂÃ,  int;
declare OnCreate(), int;
declare OnMenuPick(int nID), int;
// New functions
declare CreateMapWindows(),int;
// Variables
def m_run as int;
}

myWindow::CreateMapWindows()
{
def temp as int;
def winChild as mapWindow;

winChild.Create(30,30,50,50,
AWS_VISIBLE|AWS_AUTODRAW|AWS_AUTODRAW,
0,
"",
this);
Return 0;
}

myWindow::OnClose(), int
{
m_run = 0;
return True;
}

myWindow::OnCreate(), int
{
m_run = 1;
CenterWindow();
return true;
}

myWindow::OnMenuInit(), int
{
return true;
}

myWindow::OnMenuPick(int nID), int
{
menu m;
select (nID)
{
caseÂÃ,  FILE_OPEN:
case& FILE_CLOSE:
MessageBox(this,"Not implemented","Notice",0);
caseÂÃ,  FILE_EXIT:
m_run = 0;
caseÂÃ,  HELP_ABOUT:
MessageBox(this,
"Aurora2\n"ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  +
"(c) 2005 Speedy G\n\n" +
"All Rights Reserved",
"About...", 0);
default:
}
return True;
}

// *****************************************************************************
// *ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  MAIN SUBROUTINEÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  *
// *****************************************************************************

global sub main()
{
def winMain as myWindow;
def x,yÂÃ,  ÂÃ,  ÂÃ, as int;
def hinstÂÃ,  ÂÃ, as unsigned int;

menu m; // Unused or unready menu items are grayed
m.BeginMenu();
m.MenuTitle("&File");
m.MenuItem("&Open",ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, MF_GRAYED,ÂÃ,  FILE_OPEN);
m.MenuItem("&Close",ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  MF_GRAYED,ÂÃ,  FILE_CLOSE);
m.Separator();
m.MenuItem("E&xit",ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, MF_ENABLED, FILE_EXIT);
m.MenuTitle("&Edit");
m.MenuItem("Cut\tCtrl+X",ÂÃ,  ÂÃ, MF_GRAYED,ÂÃ,  EDIT_CUT);
m.MenuItem("Copy\tCtrl+C",ÂÃ,  MF_GRAYED,ÂÃ,  EDIT_COPY);
m.MenuItem("Paste\tCtrl+V", MF_GRAYED,ÂÃ,  EDIT_PASTE);
m.MenuTitle("&Help");
m.MenuItem("&About...",ÂÃ,  ÂÃ,  ÂÃ, MF_ENABLED, HELP_ABOUT);
m.MenuItem("&Help",ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, MF_GRAYED,ÂÃ,  HELP_HELP);
m.EndMenu();

winMain.Create(0,0,600,500,
AWS_CAPTION|AWS_VISIBLE|AWS_BORDER|AWS_SYSMENU|AWS_AUTODRAW|AWS_SIZE|
AWS_MAXIMIZEBOX|AWS_MINIMIZEBOX,
0,"Hood Map",NULL);
winMain.SetMenu(m.Detach());
winMain.CreateMapWindows();

// message loop
do
{
wait();
}until winMain.m_run = 0;
return;
}



Thanks
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Parker

Under your CreateMapWindows subroutine, change the definition to a pointer, so it will look like this:
myWindow::CreateMapWindows()
{
def temp as int;
def *winChild as mapWindow; winChild = new(mapWindow,1);

winChild->Create(30,30,50,50,
AWS_VISIBLE|AWS_AUTODRAW,
0,
"",
this);
Return 0;
}


Otherwise the winChild variable will fall out of scope and you won't be able to use it, that's what is making the program fail. So that fixes the not showing problem, but I can't seem to get it to become a child window. I use this code to make a child of the MDICLIENT:
child = CreateWindowEx(WS_EX_MDICHILD, _
wstr("fbs_child"), _
wstr("FB Source #"+str(CodeCount)), _
WS_CHILD or WS_CLIPSIBLINGS or WS_OVERLAPPEDWINDOW, _
CW_USEDEFAULT, _
CW_USEDEFAULT, _
CW_USEDEFAULT, _
CW_USEDEFAULT, _
parent, _
null, _
GetModuleHandle(null), _
null)
and it works there, but I can't get how to make a child of a normal window in Aurora. I guess we'll have to let Paul answer that one.

Ionic Wind Support Team

AWS_VISIBLE|AWS_AUTODRAW|AWS_CHILD

You have to specify.
Ionic Wind Support Team

Parker

I should have said more. I tried that, I also tried adding WS_CHILD, WS_CLIPSIBLINGS, putting WS_CLIPCHILDREN in the parent's styles, although I don't know what those do, I've seen them used. But it won't appear at all if that's used.

Ionic Wind Support Team

It's there but you can't tell because your not drawing a border or caption.


myWindow::CreateMapWindows()
{
def temp as int;
mapWindow *winChild;
winChild = new(mapWindow,1);
winChild->Create(30,30,50,50,
AWS_VISIBLE|AWS_AUTODRAW|AWS_CHILD|AWS_BORDER,
0,
"",
this);
Return 0;
}
Ionic Wind Support Team

Ionic Wind Support Team

I should also note that you should return the pointer somewhere to be deleted later or you will have memory leaks on exit.

A proper way to do this is to have member variables in your main window class.  Changes as follows:


class myWindow : window
{
//constructor and destructor
declare myWindow();
declare _myWindow();

// Overridden functions
declare OnClose(),  int;
declare OnCreate(), int;
declare OnMenuPick(int nID), int;
// New functions
declare CreateMapWindows(),int;
// Variables
def m_run as int;
mapWindow *m_child;
}

myWindow::myWindow()
{
m_child = NULL;
}

myWindow::_myWindow()
{
if(m_child <> NULL)
      delete m_child;
}

myWindow::CreateMapWindows()
{
def temp as int;
m_child = new(mapWindow,1);

m_child->Create(30,30,50,50,
AWS_VISIBLE|AWS_AUTODRAW|AWS_CHILD|AWS_BORDER,
0,
"",
this);
Return 0;
}

Ionic Wind Support Team

Bruce Peaslee

Great! This is exactly what a wanted.

Thanks to everyone for the help, and especially thanks to Paul for all of the hand holding on classes, pointers, and OOP.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Bruce Peaslee

December 24, 2005, 03:55:39 PM #15 Last Edit: December 24, 2005, 04:13:20 PM by peaslee
Back againÂÃ,  ;)

Now that I've got the cute little box (window) just how I want it, I'm trying to write something in it. From the main subroutine, no problem, I just say

m.child->WriteText(10,10,"Test").

But shouldn't any initialization of the child windows be done in their own class? I have defined


mapWindow::OnCreate(),int
{
*(mapWindow)This.WriteText(5,5,"Test");
return true;
}


but the window remains blank. Attempts at other syntax give error messages.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Ionic Wind Support Team

OnCreate is called when the window is created but before it has been shown for the first time.  At that point in the code things like the default font, bitmap for autodrawing, and other data has not been set up yet.

It is not the place for drawing anything to a window.

Paul.
Ionic Wind Support Team