tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Newcomer to TCC (and C) with a couple ofquestions..


From: fsw.fb
Subject: Re: [Tinycc-devel] Newcomer to TCC (and C) with a couple ofquestions..
Date: Fri, 03 Apr 2009 19:06:06 -0700
User-agent: Thunderbird 2.0.0.21 (Windows/20090302)

Hi,
if you want to stay with Win32 then you could look for theForger's Win32 API tutorial here:
http://www.winprog.org/tutorial/

There you can not only get a Win32 tutorial, but also some examples (afaik).

Here a short Win32 example:

#include <windows.h>
const char g_szClassName[] = "myWindowClass";

// Step 4: the Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
   switch(msg)
   {
       case WM_CLOSE:
           DestroyWindow(hwnd);
       break;
       case WM_DESTROY:
           PostQuitMessage(0);
       break;
       default:
           return DefWindowProc(hwnd, msg, wParam, lParam);
       break;  //without this break the Avira AntiVirus program will go off
   }
   return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
   WNDCLASSEX wc;
   HWND hwnd;
   MSG Msg;
//Step 1: Registering the Window Class
   wc.cbSize = sizeof(WNDCLASSEX);
   wc.style = 0;
   wc.lpfnWndProc = WndProc;
   wc.cbClsExtra = 0;
   wc.cbWndExtra = 0;
   wc.hInstance = hInstance;
   wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
   wc.hCursor = LoadCursor(NULL, IDC_ARROW);
   wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
   wc.lpszMenuName = NULL;
   wc.lpszClassName = g_szClassName;
   wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc))
   {
MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
       return 0;
   }

   // Step 2: Creating the Window
   hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,
       g_szClassName,
       "The title of my window",
       WS_OVERLAPPEDWINDOW,
       CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
       NULL, NULL, hInstance, NULL);
if(hwnd == NULL)
   {
       MessageBox(NULL, "Window Creation Failed!", "Error!",
       MB_ICONEXCLAMATION | MB_OK);
       return 0;
   }

   ShowWindow(hwnd, nCmdShow);
   UpdateWindow(hwnd);

   // Step 3: The Message Loop
   while(GetMessage(&Msg, NULL, 0, 0) > 0)
   {
       TranslateMessage(&Msg);
       DispatchMessage(&Msg);
   }

   return Msg.wParam;
}

As you can see it's really simple.

One thing though: if there is a "break" missing after the "default" in the "switch" statement then Avira Antivirus will go off and deny acces to the generated exe file. Symantec's Antivirus Software will still go off and even delete the compiled exe.

Didn't find out why yet.
Suppose the generated code is too similar to some viruses...

Hope this helps

lostgallifreyan wrote:
I'll look at those three (GDK, SDL, OpenGL). It's likely that I'll just go with 
wxDev_C++ if I like it, as it uses wxWidgets, but I do like the idea of using C 
rather than C++, if I can learn to make a program with GUI and standard 
controls using TCC and other small clean systems, that's how I want it. I don't 
have a lot of code to port to anything, but that's why I want to establish a 
course early, so I don't find myself in that position. (It's why I won't touch 
.net, as that looks like a bad choice to me). While I'll be coding for Win32 as 
I chose to stay with W98, I don't want to isolate myself too much.



_______________________________________________
Tinycc-devel mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/tinycc-devel






reply via email to

[Prev in Thread] Current Thread [Next in Thread]