Thread: CreateWindow

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    14

    CreateWindow

    Hi there. I am trying to create a window under windows XP. I included windows.h, and compiled with user32.lib.

    Code:
    CreateWindow("testname",
    	     "TestName",
    	     WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_HSCROLL | WS_VSCROLL | WS_MINIMIZEBOX | WS_TABSTOP ,
    	     CW_USEDEFAULT,
                 CW_USEDEFAULT,
    	     CW_USEDEFAULT,
    	     CW_USEDEFAULT,
                 NULL,
                 NULL,
    	     hInstance,
    	     NULL);
    I got an error message: 'hInstance' : undeclared identifier
    and two warnings: 'function' : 'HINSTANCE' differs in levels of indirection from 'int'
    'CreateWindowExA' : different types for formal and actual parameter 11

    I found lots of tutorials and examples, but all in C++.
    Is that possible, with C, to create windows and have fields where you can tipe some words, and then, they get printed on other field?

    Thanks

  2. #2
    Registered User
    Join Date
    Feb 2005
    Posts
    38
    Yes, it is possible. Here's a good api tutorial that's in C:

    http://www.winprog.org/tutorial/
    I like to play pocket pool.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    You need to have hInstance declared somewhere. It is usually declared in your WinMain function (can be named anything), if you are calling this from another function then either make hInstance global or pass it as a pointer to your function.

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    This should be in the Windows Forum.

    Are you using Dev-C++?
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-08-2006, 04:42 PM
  2. Replies: 12
    Last Post: 03-27-2006, 07:03 AM
  3. CreateWindow failure
    By TheDan in forum Windows Programming
    Replies: 6
    Last Post: 07-08-2005, 07:49 AM
  4. CreateWindow LPVOID
    By Mithoric in forum Windows Programming
    Replies: 1
    Last Post: 04-13-2004, 09:46 PM
  5. getting fed up with CreateWindow
    By ... in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2003, 03:42 PM