April 25, 2024, 05:32:35 AM

News:

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


Dedicated windows inside a class

Started by LarryMc, August 17, 2007, 09:51:57 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LarryMc

Still working on same program as window handler in class.

I have 2 windows that are used internally by the class.

When I define them in the class source file like thus:
   AUTODEFINE "OFF"
   $include "MyClass.inc"
   window m_win, m_cont
everything works fine.

when I move the defines to the include file like thus:
class MyClass
   declare MyMeth1()
   declare MyMeth2()

   window m_win
   window m_cont
end class


It will compile just fine.
When I call a method that tries to open window 'm_win' the program crashes and I get one of those "Poor baby, tell Uncle Bill all about it" messages.

Got any clues.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

J B Wood (Zumwalt)

Because m_win and m_cont is not initialized yet.

LarryMc

Quote from: Jonathan (zumwalt) Wood on August 17, 2007, 09:55:47 AM
Because m_win and m_cont is not initialized yet.

How do you initialize a window type variable in EBasic.
It doesn't like 0 or NULL.  Get compiler errors with those.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Barney

Remember that WINDOW variable is actually a TYPE. Here's the definition


TYPE WINDOW
DEF hWnd as UINT
DEF hBitmap as UINT
DEF hFont as UINT
DEF hPen as UINT
DEF hClient as UINT
DEF m_pos as POINT
DEF m_iBkMode as INT
DEF m_iROP2 as INT
DEF m_nPenStyle as INT
DEF m_nPenWidth as INT
DEF m_cBack as UINT
DEF m_cWindow as UINT
DEF m_bAutoDraw as INT
DEF m_bTabEnable as UINT
DEF m_hCursor as UINT
DEF m_hBackDC as UINT
DEF m_hCacheDC as UINT
DEF m_nCacheCount as INT
DEF m_bDialog as INT
DEF m_pDlgTemplate as POINTER
DEF m_pIB2DScreen as POINTER
DEF m_pIB2DSurface as POINTER
DEF hProcedure as UINT
DEF m_pBrowser as POINTER
DEF m_hPrintDC as UINT
ENDTYPE


So, you can probably use something like

WINDOW win1
win1.hWnd=0

to "initialize" it. The variable get initialized once you OPENWINDOW with it.

Barney

LarryMc

Barney,
I did as you suggested and it worked until I hit
BROWSECMD m_cont,@NAVIGATE,htmlpage
That statement worked perfect until I made m_cont a class member.
When I hit that one I get the "Uncle Bill" message.


Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

J B Wood (Zumwalt)

You can't use m_cont until m_cont has a value.
I am only really seeing half the picture here you are drawing so its hard to explain how to fix it.

m_cont.hWnd=0
BROWSECMD *m_cont,@NAVIGATE,htmlpage

Maybe that will work? Don't know for sure, but you pass structures as references not by value.
I don't know right now what the in's for BROWSECMD are expected as, so this might not work either.

Barney

Note that I've put quotes around initialize when I referred to win1.hWnd=0. WINDOW variable gets initialized i.e. filled with all the necessary values the moment you create a window with OPENWINDOW command. There is no other type of initialization.

Could you show as a bit more of your code?

Barney

LarryMc

Okay,
Attached are 2 zips.

Works.zip contains an exe file that works like I want it to when I declare the 2 windows a local variables to the source file.

MyClass.zip contains the source file, inc file, rc file, and project file where I'm trying to declare the 2 windows as class members.

Any and all help is always appreciated.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library