Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 146613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:38:04+00:00 2026-05-11T08:38:04+00:00

I am trying to make a Visual C++ 2008 program that plots some data

  • 0

I am trying to make a Visual C++ 2008 program that plots some data in a Window. I have read from various places the correct way to do this is to override WndProc. So I made a Windows Forms Application in Visual C++ 2008 Express Edition, and I added this code to Form1.h, but it won’t compile:

    public:     [System::Security::Permissions::PermissionSet(System::Security::Permissions::SecurityAction::Demand, Name='FullTrust')]     virtual void WndProc(Message %m) override     {         switch(m.Msg)         {             case WM_PAINT:             {                 HDC     hDC;                 PAINTSTRUCT ps;                 hDC = BeginPaint(m.HWnd, &ps);                  // i'd like to insert GDI code here                  EndPaint(m.Wnd, &ps);                 return;             }         }         Form::WndProc(m);     } 

When I try to compile this in Visual C++ 2008 Express Edition, this error occurs: error C2664: ‘BeginPaint’ : cannot convert parameter 1 from ‘System::IntPtr’ to ‘HWND’

When I try using this->Handle instead of m.HWnd the same error occurs.

When I try casting m.HWnd to (HWND), this error occurs: error C2440: ‘type cast’ : cannot convert from ‘System::IntPtr’ to ‘HWND’

Maybe I need to cast the m.HWnd to a pin_ptr or something.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T08:38:04+00:00Added an answer on May 11, 2026 at 8:38 am

    If you were making a raw Win32 application then you could use those functions.

    If, on the other hand, you are making a WinForms application then you need to override the OnPaint event.

    • Switch to the design view (The view that shows your form.)
    • Click on the title bar of your form
    • In the properties window (by default probably on your lower right screen) select the lightning bolt near the top. This will display a list of events.
    • Scroll down to the paint event and double click it.

    You will end up with a Paint routine shell from which you can use the drawing functions of the graphics object.

     private: System::Void Form1_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e)  {     e->Graphics->DrawRectangle(...)               } 

    If you really want to write raw Win32 code, let me know, and I can help you write a shell. In the time being if you are interested in Win32 I recommend Charles Petzold’s Programming Windows 5th edition.

    If you want to learn C++ WinForms… well, I recommend switching to C# or VB.NET simply because they might be more intuitive.

    Hope this helps. Cheers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 70k
  • Answers 70k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Sharepoint designer adds some borders, columns, and other crap to… May 11, 2026 at 12:56 pm
  • added an answer The problem isn't so much that a PS3 is overkill,… May 11, 2026 at 12:56 pm
  • added an answer I don't have VB.NET handy at the moment, but in… May 11, 2026 at 12:56 pm

Related Questions

I am trying to make a div, that when you click it turns into
I am trying to make a JTable that has column spans available. Specifically, I
I am trying to make a gridview sortable which uses a stored procedure as
I am trying to make a form in which the user fills in values.
I am trying to make a php login page that allows users to access
I am new to Windows and Visual Studio. I have a strong background in
I'm laying the groundwork for an automated build process and am trying to make
I need some mind reading here, since I am trying to do what I
Recently, I've been dealing with an error with accessing MAPI via the .NET framework

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.