Thread: pointer to hWnd

  1. #1
    Registered User
    Join Date
    Apr 2004

    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.

    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
    University of Waterloo
    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
    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, 03:45 AM
  2. Ban pointers or references on classes?
    By Elysia in forum C++ Programming
    Replies: 89
    Last Post: 10-30-2007, 03: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, 01:34 PM
  5. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM