need example code for a win32 window

This is a discussion on need example code for a win32 window within the Windows Programming forums, part of the Platform Specific Boards category; Originally Posted by cadcrazy Hey guys. Programming using win32 API is not supported on visual c++ 2005 edition as there ...

  1. #16
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by cadcrazy View Post
    Hey guys. Programming using win32 API is not supported on visual c++ 2005 edition as there s no windows.h supplied with it. Is there any other way out ???????
    Surely this is not right - the MFC library will NEED some Win32 API functions to work, and for a large part of it, it's supplied as source-code.

    If you can't find a windows.h in your installation, perhaps you need to install "some more stuff", or you may need to install the "Windows SDK" - which is available separately, but for free, from Microsoft.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  2. #17
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Quote Originally Posted by deian View Post
    all i want is to write a simplest win32 application which could command a hardware via parallel port (or maybe serial, i don't know yet) when i choose an option from a pop-up menu/when i enter some data from the keyboard, to show some error messages if the hardware does not work properly and other thinks like that.
    MFC dialog based application.

    Serial ports are treated as files;
    Open with 'CreateFile()' [COM1, COM2 are the 'file name']
    Get current state with 'GetCommState()' (winbase.h)
    Adjust settings, set state with 'SetCommState()'
    Get timeout settings with 'GetCommTimeouts()' 'SetCommTimeOuts()'

    Use 'WriteFile()' to send a msg through the port.
    Use 'ReadFile()' to read from the port.
    These are best used with an event 'CreateEvent()' and 'WaitForSingleObject()' to ensure the operation completes or error is returned.

    Close port with 'CloseHandle()'

    Timers (OnTimer() or WM_TIMER) msgs have low priority in the OS message queue and can be ignored. So timer resolutions under 10ms need a higher resolution timer like QueryPerformanceCounter()
    Last edited by novacain; 09-23-2007 at 08:47 PM.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #18
    Registered User
    Join Date
    May 2004
    Posts
    20

    compiler problems

    i tried to compile menutwo.c file and those attached to it from theForger's win32 Tutorial. I included all the files in a project, but the IDEs from below show the following errors:

    dev c++

    compiler
    C:\Users\deian\Documents\c_tutorial\files\source\m enu_two\menu_two.c In function `LRESULT WndProc(HWND__*, UINT, WPARAM, LPARAM)':
    29 C:\Users\deian\Documents\c_tutorial\files\source\m enu_two\menu_two.c invalid conversion from `void*' to `HICON__*'
    35 C:\Users\deian\Documents\c_tutorial\files\source\m enu_two\menu_two.c invalid conversion from `void*' to `HICON__*'
    C:\Dev-Cpp\Makefile.win [Build Error] [../Users/deian/Documents/c_tutorial/files/source/menu_two/menu_two.o] Error 1

    build log
    Compiler: Default compiler
    Building Makefile: "C:\Dev-Cpp\Makefile.win"
    Executing make...
    make.exe -f "C:\Dev-Cpp\Makefile.win" all
    g++.exe -c ../Users/deian/Documents/c_tutorial/files/source/menu_two/menu_two.c -o ../Users/deian/Documents/c_tutorial/files/source/menu_two/menu_two.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"

    ../Users/deian/Documents/c_tutorial/files/source/menu_two/menu_two.c: In function `LRESULT WndProc(HWND__*, UINT, WPARAM, LPARAM)':
    ../Users/deian/Documents/c_tutorial/files/source/menu_two/menu_two.c:29: error: invalid conversion from `void*' to `HICON__*'

    ../Users/deian/Documents/c_tutorial/files/source/menu_two/menu_two.c:35: error: invalid conversion from `void*' to `HICON__*'

    make.exe: *** [../Users/deian/Documents/c_tutorial/files/source/menu_two/menu_two.o] Error 1

    Execution terminated

    code blocks

    Switching to target: default
    Compiling: ..\..\Documents\c_tutorial\files\source\menu_two\m enu_two.c
    mingw32-gcc.exe: installation problem, cannot exec `cc1': No such file or directory
    Process terminated with status 1 (0 minutes, 0 seconds)

    i have also tried to compile some simple C codes for a DOS console application as a simple file and as a project, and they show "undefined type" errors at some functions, linker errors, or error like the one above (from codeblocks, altough cc1.exe and ccplus.exe files do exist in the package folders !)
    ). Microsoft Visual Studio 2005 is even worse. i don't remember the errors but it's worse anyway.
    what should i do ?

  4. #19
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Both dev-cpp and msvc2005 have options for creating a windows application (gui, may be the specific option referred to by dev-cpp) so you should make sure you create the right project type.

    Most compilers are smart enough to recognise a *.c as a c file and *.cpp as c++ but the ide's that interface with them usually have default options set when you create a project which may include what the language used is, regardless of source code file extension. So you also need to be aware that you'll probably need to specify whether you want to compile your project as c or c++ - those 'invalid conversion' errors from dev-cpp are because you are attempting to compile c code as c++. The code::blocks issues look, at first glance, to be configuration problems, too. The msvc errors you allude to are likely, again, a result of incorrect project creation selection; there may also be some unicode issues but, without specific information from you, there's not much point in speculating further about it.

    Rather than jumping around from place to place, pick one ide, whichever you find the simplest at present and fiddle around with creating new projects until you are comfortable with the various options available and the results produced. Since you seem to be closest to a result with dev-cpp, it would seem prudent to stick with that at present.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  2. Problems with standard WIN32 Code
    By BruceLeroy in forum Windows Programming
    Replies: 6
    Last Post: 08-24-2004, 10:20 AM
  3. dont want to use all params
    By stallion in forum Windows Programming
    Replies: 2
    Last Post: 02-18-2003, 08:10 AM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 11:12 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM

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