pointer to hWnd

This is a discussion on pointer to hWnd within the Windows Programming forums, part of the Platform Specific Boards category; how can i access my programs main hWnd in my class without making it global and externing it? Im currently ...

  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    2

    pointer to hWnd

    how can i access my programs main hWnd in my class without making it global and externing it? Im currently trying to access it by passing it's memory address to my class using functions but all it seems to pass is garbage.

    Code:
    void Paddle::SethWnd(HWND *hWnd)
    {
    	hWindow = hWnd;
    }
    HWND* Paddle::GethWnd()
    {
    	return hWindow;
    }
    these are currently the functions i am using to pass it, and access it.
    hWindow is a private member variable of the class and is a HWND*.
    Ive tryed calling the SethWnd function in InitInstance and in WndProc either way i seem to get garbage, thanks in advance for any help.

  2. #2
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,904
    HWND is already a pointer and will not change throughout your program unless you manually change it. In other words:

    just pass HWND hwnd, not HWND *hwnd

  3. #3
    Registered User
    Join Date
    Apr 2004
    Posts
    2
    ah I see, just did a recompile and now i see my paddle on the screen, thanks alot.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 04-04-2009, 04:45 AM
  2. Ban pointers or references on classes?
    By Elysia in forum C++ Programming
    Replies: 89
    Last Post: 10-30-2007, 04:20 AM
  3. Menu like file, edit, help, etc...
    By Livijn in forum Windows Programming
    Replies: 44
    Last Post: 01-23-2007, 05:49 PM
  4. towers of hanoi problem
    By aik_21 in forum C Programming
    Replies: 1
    Last Post: 10-02-2004, 02:34 PM
  5. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 08:48 PM

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