Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / December 2004

Tip: Looking for answers? Try searching our database.

WIN32 Window Classes with WIndows Forms

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve Marsden - 10 Dec 2004 10:21 GMT
Hi

With WIN32 you could create your own Window Class (not C++ Class) which you
registered with RegisterClass, create and code a windowproc for this window
and then host that window on a dialog box using the Custom Control and
specifying class as the name of the Window Class you registered and hey
presto you could have your own window/control on a dialogbox.

Is there a way to do this with a Windows Form.

We have a large WIN32 C application which we have just complied with /CLR
and are starting to slowly convert/integrate with ..NET and Windows Forms
but we have quite a few of these Window Classes which for now it would be
great to host on a Windows Form rather have to port all the code to C++ and
Object Classes etc.

Anyone know if this is possible and how?

Thanks

Steve
Mattias Sj?gren - 10 Dec 2004 23:35 GMT
Steve,

>Anyone know if this is possible and how?

Create a class derived from Control, override the CreateParams
property and use it to return the window class to use.

Mattias

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Steve Marsden - 13 Dec 2004 12:42 GMT
Mattias

Thanks for the reply. This sounds hopeful.

As a newbie I am OK creating the class derived from Control but nor sure
about overiiding the CreateParams property and returnng the windows class.

Could you gove me a short example.

Thanks

Steve
> Steve,
>
[quoted text clipped - 4 lines]
>
> Mattias
Steve Marsden - 13 Dec 2004 14:49 GMT
Further to the above I found some code which shoudl do what I want but it
fails with "Invalid Window Class Name"

public __gc class testclass : public System::Windows::Forms::Control
{
protected:
   __property System::Windows::Forms::CreateParams * get_CreateParams()
   {
   System::Windows::Forms::CreateParams * createParams;
   createParams = __super::get_CreateParams();
   createParams->ClassName = "generic";
   return createParams;
   }
};

generic is a class I already have registered using RegisterClass elseeher in
my project

wndclass.lpszClassName="generic";
wndclass.lpfnWndProc=GenericProc;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=dlgbkbr;
if (!RegisterClass(&wndclass))
   return -1;

If I change "generic" to "BUTTON" so I am using a system class it works but
not with my own window class
Steve Marsden - 13 Dec 2004 15:42 GMT
I am tried changing my class stytle to CS_GLOBALCLASS and this removed the
error.

My only remaining problem now is my control is not being painted.

I have debugged I am definitely getting into the wndproc for my class but I
am not getting any WM_PAINT messages.

Any ideas?
Steve Marsden - 13 Dec 2004 15:47 GMT
PS I am getting WM_CREATE, WM_KEYDOWN messages just no WM_PAINT messages

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.