473,473 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Small Problem with Type Casting

Okay, here's my calling code:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
mdiClient = New MDIClientWindow(Me, Me.Handle) '**
SetClassLong(mdiClient.Handle, GCL_HBRBACKGROUND, 0)
End Sub ' End Form1_Load

Here's the Code Being Called:

Public Sub New(ByVal i As IMDIClientNotify, ByVal handle As IntPtr)
'Find the MDI Client window handle:
GetWindows(handle)
If Not hWndMdiClient.ToInt32 = IntPtr.Zero.ToInt32 Then
MyBase.AssignHandle(hWndMdiClient)
End If
notify = i
End Sub ' End Sub New

And here is the Interface:

Public Interface IMDIClientNotify
Sub WndProc(ByRef m As Message, ByRef doDefault As Boolean)
End Interface

Here's the origional C# code for the above functions:

private void mfrmMDIClientPaint_Load(object sender, System.EventArgs e)
{
// Start processing for MDIClient window messages:
mdiClient = new MDIClientWindow(this, this.Handle);
// Stop the default window proc from drawing the MDI background
// with the brush:
UnManagedMethods.SetClassLong(
mdiClient.Handle,
UnManagedMethods.GCL_HBRBACKGROUND,
0);
}

public MDIClientWindow(IMDIClientNotify i, IntPtr handle)
{
// Find the MDI Client window handle:
GetWindows(handle);
if (hWndMdiClient != IntPtr.Zero)
{
this.AssignHandle(hWndMdiClient);
}
this.notify = i;
}

public interface IMDIClientNotify
{
void WndProc(ref Message m, ref bool doDefault);
}

The '** Mark is where things go heywire!

"Additional information: Specified cast is not valid." is the exact error
that comes up, if that helps...

Thanks again,
Sueffel
Nov 20 '05 #1
9 940
"Tibby" <Bl**@rent.com> schrieb
mdiClient = New MDIClientWindow(Me, Me.Handle) '**
The '** Mark is where things go heywire!

"Additional information: Specified cast is not valid." is the exact error
that comes up, if that helps...


What is the full message? What are the source and destination types of the
cast? What's the type of mdiClient? Is it "MDIClientWindow" or one of it's
base classes? Did you enable Option Strict?
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2

"Armin Zingler" <az*******@freenet.de> wrote in message
news:u6*************@TK2MSFTNGP11.phx.gbl...
"Tibby" <Bl**@rent.com> schrieb
mdiClient = New MDIClientWindow(Me, Me.Handle) '**


The '** Mark is where things go heywire!

"Additional information: Specified cast is not valid." is the exact error that comes up, if that helps...


What is the full message? What are the source and destination types of the
cast? What's the type of mdiClient? Is it "MDIClientWindow" or one of it's
base classes? Did you enable Option Strict?
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


Okay, the zip file is at http://www.tiberiansun.us/Test.zip

Sueffel
Nov 20 '05 #3

"Armin Zingler" <az*******@freenet.de> wrote in message
news:u6*************@TK2MSFTNGP11.phx.gbl...
"Tibby" <Bl**@rent.com> schrieb
mdiClient = New MDIClientWindow(Me, Me.Handle) '**


The '** Mark is where things go heywire!

"Additional information: Specified cast is not valid." is the exact error that comes up, if that helps...


What is the full message? What are the source and destination types of the
cast? What's the type of mdiClient? Is it "MDIClientWindow" or one of it's
base classes? Did you enable Option Strict?
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


Not sure if I can answer those questions, I'm flying blind as is! LOL
But, I can zip up the project and attach it here. I do know that option
strict is off at the moment. I know how much people love it when there's
binary data attached to a thread. But anyhew, I'm trying to implement this
as a nifty to take away the boring MDI Interface and make it look a little
more snatzy.

Thanks again,
Sueffel


Nov 20 '05 #4
"Sueffel" <so*****@somewhere.com> schrieb


Okay, the zip file is at http://www.tiberiansun.us/Test.zip


You did not enable Option Strict!

You get the exception because Form1 does not implement IMDIClientNotify.
Implement the interface and the project will be compilable (after removing
the other two errors).
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5

"Armin Zingler" <az*******@freenet.de> wrote in message
news:eN**************@TK2MSFTNGP10.phx.gbl...
"Sueffel" <so*****@somewhere.com> schrieb


Okay, the zip file is at http://www.tiberiansun.us/Test.zip


You did not enable Option Strict!

You get the exception because Form1 does not implement IMDIClientNotify.
Implement the interface and the project will be compilable (after removing
the other two errors).
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


That was the one thing I was missing, the implementation! Thank you
sooooooo much! No I just have to figure out the PInvoke Errors and I'm good
to go!

Thanks again,
Tibby

PS - Sorry bout the Option Strict, I have a long time aversion to it.
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.558 / Virus Database: 350 - Release Date: 1/2/2004
Nov 20 '05 #6

"Sueffel" <so*****@somewhere.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...

"Armin Zingler" <az*******@freenet.de> wrote in message
news:eN**************@TK2MSFTNGP10.phx.gbl...
"Sueffel" <so*****@somewhere.com> schrieb
>

Okay, the zip file is at http://www.tiberiansun.us/Test.zip
You did not enable Option Strict!

You get the exception because Form1 does not implement IMDIClientNotify.
Implement the interface and the project will be compilable (after removing the other two errors).
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


That was the one thing I was missing, the implementation! Thank you
sooooooo much! No I just have to figure out the PInvoke Errors and I'm

good to go!

Thanks again,
Tibby

PS - Sorry bout the Option Strict, I have a long time aversion to it.
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.558 / Virus Database: 350 - Release Date: 1/2/2004


BTW, how can I trap a "Unhandled exception of type
'System.StackOverflowException' occured in system.dll" ? I know that that
one has something to do with circular reference, but I'm not seeing it...
*sigh* All kinds of nifty errors with this code. Unfortunatly, I don't have
the time to "Learn" what is going on, so I may have to scrap this project
:(

Thanks again
Sueffel
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.558 / Virus Database: 350 - Release Date: 1/2/2004
Nov 20 '05 #7
"Sueffel" <so*****@somewhere.com> schrieb
That was the one thing I was missing, the implementation! Thank
you sooooooo much! No I just have to figure out the PInvoke Errors
and I'm good to go!

....and:
Why do you need pInvoke here? Native window sub classing is often not
necessary anymore. You can override WndProc.
--
Armin

Nov 20 '05 #8

"Armin Zingler" <az*******@freenet.de> wrote in message
news:OH**************@TK2MSFTNGP09.phx.gbl...
"Sueffel" <so*****@somewhere.com> schrieb
That was the one thing I was missing, the implementation! Thank
you sooooooo much! No I just have to figure out the PInvoke Errors
and I'm good to go!

...and:
Why do you need pInvoke here? Native window sub classing is often not
necessary anymore. You can override WndProc.
--
Armin


API Calls... That is the example that was shown to me.... I'm not spiffey
with graphics, try to avoid them if possible actually, but I just thought it
would be a nice touch to the GUI, but I do have time contraints and can go
back later and insitute it.... Or maybe just take the origional C# code,
throw it into a DLL, and inherit from that.?.?. That may not work. Hmmmmmm

Thanks agian,
Sueffel
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.558 / Virus Database: 350 - Release Date: 1/2/2004
Nov 20 '05 #9
"Armin Zingler" <az*******@freenet.de> schrieb
...and:
Why do you need pInvoke here? Native window sub classing is often
not necessary anymore. You can override WndProc.


Ignore my message... you do override windproc.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Graham Nicholls | last post by:
Hi. I'm having some fun with numbers. I've extraced an image sizes from a jpeg file img_x,img_y=image.getsize() then I'm trying to use those sizes to scale the image, but because python...
28
by: Robert Gamble | last post by:
I was taking a look at some of the C puzzles at: http://purana.csa.iisc.ernet.in/~gkumar/cquestions.html and have not had any trouble with any of them except for the first one which is reproduced...
11
by: truckaxle | last post by:
I am trying to pass a slice from a larger 2-dimensional array to a function that will work on a smaller region of the array space. The code below is a distillation of what I am trying to...
3
by: Simon Harvey | last post by:
Hi all, I hope someone can help me with the following: I have a number of usercontrols that I've made which provides certain audit functions for any data inserted into it. Each audit control...
23
by: René Nordby | last post by:
Hi there, Is there anyone that knows how to do the following? I have a class A and a class B, that 100% inherits from class A (this means that I don't have other code in class B, than...
6
by: kalyan.listsubs | last post by:
Hi, I have the below program which will simply write struct employee to a file (binary mode). The problem here is empid is writen to the file but the name (char name) is not written. I am using...
13
by: Alan Silver | last post by:
Hello, MSDN (amongst other places) is full of helpful advice on ways to do data access, but they all seem geared to wards enterprise applications. Maybe I'm in a minority, but I don't have those...
169
by: JohnQ | last post by:
(The "C++ Grammer" thread in comp.lang.c++.moderated prompted this post). It would be more than a little bit nice if C++ was much "cleaner" (less complex) so that it wasn't a major world wide...
0
by: Tarik Monem | last post by:
I have been working on an all AJAX/DOM web site which is set to go live today and I thought I'd share my discoveries with all of you whom have helped me when I have encountered different issues along...
4
by: Wally Barnes | last post by:
Can someone help a poor C++ programmer that learned the language before there was a standard lib .. etc ? Basically I have two classes that look something like below: template <class T>...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.