extremely simple help

This is a discussion on extremely simple help within the Windows Programming forums, part of the Platform Specific Boards category; this is a really simple question that i do not know the answer to, as i have barely started win ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    3

    Question extremely simple help

    this is a really simple question that i do not know the answer to, as i have barely started win apps, and as my name suggests i can only about get DOS programming right. I am having problems with this line of code:
    Code:
    case WM_PAINT: 
    			hDC = BeginPaint(hwnd,&paintStruct);
    this may sound stupid, but can anyone tell me what im doing wrong?^_^ please?

  2. #2
    Registered User
    Join Date
    Apr 2007
    Posts
    3
    so no one can help...

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    There's nothing wrong with that code per se. See the MSDN page for BeginPaint() and this example. There must be something wrong with how you declare your variables. How is paintStruct declared?

    BTW, in future, post questions like this in the Windows programming forum.

    [edit]
    so no one can help...
    You only waited nine minutes. I would wait a little longer than that before assuming that no one can help. [/edit]
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    Welcome to the boards. If you haven't already done so then please take some time to familiarise yourself with the faq:
    http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

    Make sure you have a look at the the posting guidelines:
    http://cboard.cprogramming.com/annou...ouncementid=51
    Following the rules will ensure you get a prompt answer to your question.

    Remember, too, that the board has a search facility, a link is at the top of your screen:
    http://cboard.cprogramming.com/search.php
    It will often get you a quicker answer to your questions than waiting for a response to one you have posted.


    If you have any questions about this you may ask or you can contact one of our forum leaders:

    http://cboard.cprogramming.com/showgroups.php


    ---------------------------------------------------------


    A couple of notes on your first question. You should explain what you mean by "having problems". Is it a compile error? Does it compile but give an unexpected result when you run it? Give as much detail about the problem you are having as possible.

    Also, please don't bump threads after 9 minutes with comments like that. This is not a chatroom. People often don't get responses for hours or sometimes even a day or two here, depsite this being a popular forum. Be patient, if somebody has an answer for you, they will respond.

    Finally, this looks to be windows specific. There is a separate forum here for Windows specific issues. Future questions like this would be better posted there.

  5. #5
    Registered User
    Join Date
    Apr 2007
    Posts
    3
    it tells me that `paintStruct' undeclared (first use this function)
    would anyother code affect that?
    Does
    Code:
    case WM_CREATE:
                return 0;
                break;
                
                case WM_CLOSE:
                     return 0;
                     break;
                     
                   case WM_PAINT: 
    			hDC = BeginPaint(hwnd,&paintStruct);
    have anything to do with it?

  6. #6
    Registered User
    Join Date
    Dec 2006
    Location
    Scranton, Pa
    Posts
    252
    This is actually a windows programming question.

    Anyhoo, you haven't declared with paintStruct is. The compiler doesn't know by default, it could be anything from a handle to a string name, in spite of obvious desired definition.

    PAINTSTRUCT paintStruct; // is what you are missing...

    Most seem to prefer;

    PAINTSTRUCT ps;

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,485
    Moved
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple message encryption
    By Vicious in forum C++ Programming
    Replies: 10
    Last Post: 11-07-2004, 10:48 PM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  3. Simple simple program
    By Ryback in forum C++ Programming
    Replies: 10
    Last Post: 09-09-2004, 05:48 AM
  4. Need help with simple DAQ program
    By canada-paul in forum C++ Programming
    Replies: 12
    Last Post: 03-15-2002, 07:52 AM
  5. Extremely Simple Graphics In Dos
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 03-07-2002, 06:25 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21