Hi everyone, I just downloaded and registered Visual c++ 2008 express edition so that i can learn win32 programming. How do I get started? any help will be very much appreciated(I have been using borland C++ !!)
<<fake signature, click here to make a signature>>

Dani AI

Generated

Short, practical roadmap to go from “console hello” to real Win32 GUI programming.

A console program (as suggested) is fine to learn basic C++, but Win32 GUI code uses a different entry point and event model: an application registers a window class, creates a window, runs a message loop, and handles events in a window procedure (WndProc). ’s shout-outs to MSDN and Petzold are good — Petzold remains the classic — but also use Microsoft’s up-to-date Win32 walkthroughs and the Windows SDK for headers, libraries and samples: Learn to program for Windows (Win32).

Quick checklist

  • Install the Windows SDK if Visual C++ can’t find windows.h or Win32 libraries.
  • Create a “Windows Desktop”/empty project, add a .cpp, and implement WinMain, a window class and a message loop.
  • Don’t use void main() — use int main for console or int WINAPI WinMain(...) for GUI.
  • If you get linker errors about the entry point, check the project subsystem (Console vs Windows) and your entry function.

Minimal skeleton (start point)

#include <windows.h>

LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    if (msg == WM_DESTROY) { PostQuitMessage(0); return 0; }
    return DefWindowProc(hWnd, msg, wParam, lParam);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int nShowCmd)
{
    WNDCLASS wc; ZeroMemory(&wc, sizeof(wc));
    wc.lpfnWndProc = WndProc; wc.hInstance = hInstance; wc.lpszClassName = "MyWinClass";
    if (!RegisterClass(&wc)) return 0;
    HWND hwnd = CreateWindow("MyWinClass", "Title", WS_OVERLAPPEDWINDOW,
                             CW_USEDEFAULT, CW_USEDEFAULT, 640, 480,
                             NULL, NULL, hInstance, NULL);
    ShowWindow(hwnd, nShowCmd); UpdateWindow(hwnd);
    MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); }
    return (int)msg.wParam;
}

Troubleshooting notes: missing headers -> install/configure the Windows SDK; unresolved WinMain -> wrong subsystem or wrong entry signature. If using a modern system, consider Visual Studio Community (free) for easier templates and up-to-date toolchains: https://visualstudio.microsoft.com/vs/community/.

Recommended Answers

All 4 Replies

Hi everyone, I just downloaded and registered Visual c++ 2008 express edition so that i can learn win32 programming. How do I get started? any help will be very much appreciated(I have been using borland C++ !!)
<<fake signature, click here to make a signature>>

crete CPP file and write following code

#include<iostream>
using namespace std;
void main()
{
cout<<"hiii";
}

then press ctrl+F5

omar, I did not say I can not write code , obviously you are a new poster. What I asked for was a documentation on how to program WIN32 applications. Thanks anyway for your 'advice'..

If you want good ol' Win32 this is the stuff http://www.winprog.org/tutorial/ And of course there's Petzold's Programming Windows 5th Ed which is a very very highly regarded text (I've never read it but I'm not much into straight API programming).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.