HWND pointer

This is a discussion on HWND pointer within the Windows Programming forums, part of the Platform Specific Boards category; I am making a linked list with this struct: Code: typedef struct _item{ int index; HWND hParent; HWND hChild; char ...

  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    38

    HWND pointer

    I am making a linked list with this struct:
    Code:
    typedef struct _item{
    	int index;
    	HWND hParent;
    	HWND hChild;
    	char * Name;
    	struct _item * next;
    } item, *pitem;
    I am having troubles with a hwnd pointer.
    like:
    Code:
    pitem something;
    something->index = 1;
    some->hParent = CreateWindowEx(0,szClassName,
                                 "test",WS_OVERLAPPEDWINDOW,
                                CW_USEDEFAULT, CW_USEDEFAULT, 
                                  500, 500, hwnd, 0, gInstance, 0);
    ^freezes the program.
    ANyone could point me into the right direction it would be
    appreciated

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    You have no memory allocated for pitem in your sample code. Do either:
    Code:
    item something;
    or
    Code:
    pitem something = malloc(sizeof(struct item));

  3. #3
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    I think
    Code:
    some->hParent = CreateWindowEx(0,szClassName,
                                 "test",WS_OVERLAPPEDWINDOW,
                                CW_USEDEFAULT, CW_USEDEFAULT, 
                                  500, 500, hwnd, 0, gInstance, 0);

    should be:
    Code:
    
    something->hParent = CreateWindowEx(0,szClassName,
                                 "test",WS_OVERLAPPEDWINDOW,
                                CW_USEDEFAULT, CW_USEDEFAULT, 
                                  500, 500, hwnd, 0, gInstance, 0);
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  4. #4
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    Quote Originally Posted by bithub
    You have no memory allocated for pitem in your sample code. Do either:
    Code:
    item something;
    or
    Code:
    pitem something = malloc(sizeof(struct item));


    or the c++ way:
    Code:
    pitem something = new pitem;
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  5. #5
    Registered User
    Join Date
    Dec 2004
    Posts
    38
    Thank you very much, I am new to linked list, forgot to allocate memory for it.

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. towers of hanoi problem
    By aik_21 in forum C Programming
    Replies: 1
    Last Post: 10-02-2004, 01:34 PM
  4. pointer to hWnd
    By trepid in forum Windows Programming
    Replies: 2
    Last Post: 08-05-2004, 05:16 PM
  5. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM

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