March 28, 2024, 05:47:41 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Alpha update 12/14/2005

Started by Ionic Wind Support Team, December 14, 2005, 08:04:53 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Ionic Wind Support Team

Aurora has once again been update.   Redownload from the link provided when you purchased and reinstall.

Changes/Additions:
-------------------------
- MENU class added
- #autodefine "off" now works
- 'break' has been fixed and now works to break out of FOR and WHILE loops
- Example program 'lines.src' added
- A bug causing vtables to be generated when a class wasn't in use was fixed.

New methods added to the window class:
----------------------------------------------------------
Handlers:
------------
OnCommand
OnControl
OnMenuPick
OnMenuInit
OnNotify

General methods:
------------------------
SetMenu
GetMenu
DrawMenuBar
ShowContextMenu

Information about the menu class
----------------------------------------------
For a general example of how to use the class refer to 'lines.src'.  The menu class has methods for low level menu creation as well as high level commands.  Below is an example of using both methods to create the same menu:


        //low level method
menu m,popup;
m.CreateMenu();
popup.CreateMenu(1);
popup.AppendMenu("Quit",0,1);
m.AppendMenu("&File",0x10,popup.m_hMenu);
popup.CreateMenu(1);
popup.AppendMenu("Clear",0,2);
m.AppendMenu("&Options",0x10,popup.m_hMenu);



        //high level method
m.BeginMenu();
m.MenuTitle("&File");
m.MenuItem("Quit",0,1);
m.MenuTitle("&Options");
m.MenuItem("Clear",0,2);
        m.EndMenu();


Both have their uses.  The low level method is good for creating menus that may have non text items, such as bitmaps.  The high level method can only create text menus but does so very quickly.

The menu class is self contained and does not need to be associated with a window.  The member variable 'm_hMenu' contains the handle to the OS menu. 

When the menu class goes out of scope (at the end of a subroutine) or is destroyed with 'delete' the internal OS menu is also destroyed to prevent any memory leaks.  To get a handle to the menu, and associate it with a window, use the Detach method.


MyWindow win;
win.SetMenu(m.Detach());


Detach returns the menu handle and sets the member variable m_hMenu to NULL so it can't be destroyed when the menu class is deleted.

To get the menu of a window, to change it's items or add additional ones, use the Attach method:


Menu m;
m.Attach(win.GetMenu());
m.CheckMenuItem(4, TRUE);
m.Detach();

It is important to remember to Detach the menu class from the handle returned by GetMenu.  Once a menu is set in a window it is 'owned' by that window.

Other Notes:
-----------------
If you override OnCommand or OnNotify in a derived window class be sure to call the base class implimentation.  Failing to do so will cause OnControl and OnMenuPick to not be called.

Have fun until the next update.

Paul.
Ionic Wind Support Team

Brian

Hi,

Didn't see 'lines.src' included in the update

I compiled the sample lines program from the forum, and I got this:

Compiling...
lineswindow.src
File: C:\Program Files\Aurora\examples\lineswindow.src (45) undefined variable - LSSOLID
File: C:\Program Files\Aurora\examples\lineswindow.src (75) unknown type
File: C:\Program Files\Aurora\examples\lineswindow.src (76) undefined variable - m
File: C:\Program Files\Aurora\examples\lineswindow.src (76) unknown class
File: C:\Program Files\Aurora\examples\lineswindow.src (77) undefined variable - m
File: C:\Program Files\Aurora\examples\lineswindow.src (77) unknown class
File: C:\Program Files\Aurora\examples\lineswindow.src (78) undefined variable - m
File: C:\Program Files\Aurora\examples\lineswindow.src (78) unknown class
File: C:\Program Files\Aurora\examples\lineswindow.src (79) undefined variable - m
File: C:\Program Files\Aurora\examples\lineswindow.src (79) unknown class
File: C:\Program Files\Aurora\examples\lineswindow.src (80) undefined variable - m
File: C:\Program Files\Aurora\examples\lineswindow.src (80) unknown class
File: C:\Program Files\Aurora\examples\lineswindow.src (81) Warning: undeclared function 'DrawMenuBar'
File: C:\Program Files\Aurora\examples\lineswindow.src (88) unknown type
File: C:\Program Files\Aurora\examples\lineswindow.src (89) undefined variable - m
File: C:\Program Files\Aurora\examples\lineswindow.src (89) unknown class
File: C:\Program Files\Aurora\examples\lineswindow.src (90) undefined variable - m
File: C:\Program Files\Aurora\examples\lineswindow.src (90) unknown class
File: C:\Program Files\Aurora\examples\lineswindow.src (91) undefined variable - m
File: C:\Program Files\Aurora\examples\lineswindow.src (91) unknown class
File: C:\Program Files\Aurora\examples\lineswindow.src (92) undefined variable - m
File: C:\Program Files\Aurora\examples\lineswindow.src (92) unknown class
File: C:\Program Files\Aurora\examples\lineswindow.src (93) undefined variable - m
File: C:\Program Files\Aurora\examples\lineswindow.src (93) unknown class
File: C:\Program Files\Aurora\examples\lineswindow.src (94) undefined variable - m
File: C:\Program Files\Aurora\examples\lineswindow.src (94) unknown class
File: C:\Program Files\Aurora\examples\lineswindow.src (95) undefined variable - m
File: C:\Program Files\Aurora\examples\lineswindow.src (95) unknown class
File: C:\Program Files\Aurora\examples\lineswindow.src (96) undefined variable - m
File: C:\Program Files\Aurora\examples\lineswindow.src (96) unknown class
File: C:\Program Files\Aurora\examples\lineswindow.src (97) undefined variable - m
File: C:\Program Files\Aurora\examples\lineswindow.src (97) unknown class
File: C:\Program Files\Aurora\examples\lineswindow.src (98) undefined variable - m
File: C:\Program Files\Aurora\examples\lineswindow.src (98) unknown class
File: C:\Program Files\Aurora\examples\lineswindow.src (101) unknown method
Error(s) in compiling "C:\Program Files\Aurora\examples\lineswindow.src"

Just downloaded the latest update . . .

Brian

Bruce Peaslee

It's in examples. It compiles fine 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

Ionic Wind Support Team

Perhaps the install didn't take.   Redownload and make sure your reinstall with Aurora closed.
Ionic Wind Support Team

Brian

OK, all's well. Our proxy server had a cached version of an earlier setup download,
and gave me that instead of the new version

Got the right one now, and lines.src compiles OK

Thanks,

Brian

Bruce Peaslee

December 19, 2005, 10:14:26 AM #5 Last Edit: December 19, 2005, 10:49:27 AM by peaslee
Could we have an example or two on how to use the OnCommand, OnControl, and OnNotify methods? I have this big button that just sits in my window and doesn't do anythingÂÃ,  ;)

Edit: never mind. I figured out how to detect the button click.
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

If you still want it,

#typedef UINT unsigned int

DECLARE IMPORT,CreateWindowEx alias "CreateWindowExA"(dwExStyle as UINT,
lpClassName as STRING,
lpWindowName as STRING,
dwStyle as UINT,
x as INT,
y as INT,
nWidth as INT,
nHeight as INT,
hWndParent as UINT,
hMenu as UINT,
hInstance as UINT,
lpParam as POINTER),INT;
declare import, GetModuleHandle alias "GetModuleHandleA"(string *lpszmodulename);

class testwindow : window
{
declare OnCreate(),int;
declare OnClose(),int;
declare OnControl(int nID, int nNotifyCode, unsigned int hControl),int;
declare OnCommand(unsigned int wparam,unsigned int lparam),int;
declare OnNotify(int code,int nID,NMHDR *pnmhdr),int;
}

testwindow::OnCreate()
{
CenterWindow();
CreateWindowEx(0, "BUTTON", "Test", 0x50000000, 5, 5, 70, 20, *(testwindow)this.m_hWnd, 0, GetModuleHandle(null), 0);
return true;
}

testwindow::OnClose()
{
Destroy();
return true;
}

testwindow::OnControl(int nID, int nNotifyCode, unsigned int hControl)
{
MessageBox(this, "Control "+str$(nID)+" was used. Notify code is "+str$(nNotifyCode)+
".\nThe handle is "+str$(hControl), "Control recieved notification");
window!!OnControl(nID, nNotifyCode, hControl);
return true;
}

testwindow::OnCommand(unsigned int wparam,unsigned int lparam)
{
MessageBox(this, "WM_COMMAND message was recieved. wParam = "+str$(wparam)+", lParam = "+str$(lparam),"OnCommand");
window!!OnCommand(wparam,lparam);
return true;
}

testwindow::OnNotify(int code,int nID,NMHDR *pnmhdr)
{
MessageBox(this, "WM_NOTIFY was recieved. You can check the message code, the ID, and the NMHDR structure in this function.", "OnNotify");
window!!OnNotify(code, nID, pnmhdr);
return true;
}

global sub main()
{
testwindow win;
win.Create(0, 0, 500, 500, AWS_VISIBLE|AWS_OVERLAPPEDWINDOW, 0, "Test window", 0);
do
{
wait();
} until (win.m_hWnd = 0);
return 0;
}


If you're using something like Scintilla, you'll get the WM_NOTIFY (OnNotify) messages.

Bruce Peaslee

Thanks. Very useful.

I assume that

window!!OnControl(nID, nNotifyCode, hControl);

is passing the message onward. Is that always necessary?

It took me some time to discover (because I stopped reading the MS explanation of CreateWindowExA too soonÂÃ,  :PÂÃ,  ) that the control id number is passed by hMenu in the call.
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

I don't think it's necessary. I had forgotten that AWS_VISIBLE needs to be used, and tried whatever I could to make it work correctly :)

Bruce Peaslee

Quote from: Parker on December 19, 2005, 11:54:11 AM
I ... tried whatever I could to make it work correctly :)

Don't we all! I enjoy the spirit of discovery that alpha versions bring.ÂÃ,  8)
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles