#include <windows.h>
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
char szClassName[ ] = "CodeBlocksWindowsApp";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nCmdShow)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default colour as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Code::Blocks Template Windows App", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nCmdShow);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static POINT point;
switch (message) /* handle the messages */
{
case WM_CREATE:
point.x = -1; // noch nicht gesetzt deswegen -1
point.y = -1;
return 0;
case WM_RBUTTONDOWN: // wenn Rechte Maustaste gedrückt wurde
InvalidateRect(hwnd, NULL, TRUE); // alles neuzeichen
return 0;
case WM_LBUTTONDOWN:
{
HDC hdc = GetDC(hwnd);
{
SetPixel(hdc, LOWORD(lParam), HIWORD(lParam),RGB( rand()%256, rand()%256, rand()%256));
}
ReleaseDC(hwnd,hdc);
point.x = LOWORD(lParam);
point.y = HIWORD(lParam);
return 0;
}
case WM_LBUTTONUP:
{
if(point.x != -1)
{
HDC hdc = GetDC(hwnd);
MoveToEx(hdc, point.x, point.y, NULL);
LineTo(hdc,LOWORD(lParam),HIWORD(lParam));
ReleaseDC(hwnd, hdc);
point.x = -1;
point.y = -1;
}
return 0;
}
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
-------------- Build: Debug in ddds ---------------
main.cpp
main.cpp(1) : error C2059: syntax error : '+'
main.cpp(30) : error C2332: 'class' : missing tag name
main.cpp(32) : error C2001: newline in constant
main.cpp(32) : error C2015: too many characters in constant
main.cpp(35) : error C2332: 'class' : missing tag name
main.cpp(39) : error C2001: newline in constant
main.cpp(39) : error C2015: too many characters in constant
main.cpp(43) : error C2653: 'Code' : is not a class or namespace name
main.cpp(83) : error C2143: syntax error : missing ';' before '.'
main.cpp(83) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
main.cpp(88) : error C2065: 'hwnd' : undeclared identifier
main.cpp(88) : error C2065: 'NULL' : undeclared identifier
main.cpp(88) : error C2065: 'TRUE' : undeclared identifier
main.cpp(88) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
main.cpp(88) : error C2078: too many initializers
main.cpp(88) : error C2143: syntax error : missing ';' before '+'
main.cpp(92) : error C2059: syntax error : '+'
main.cpp(105) : error C2059: syntax error : '+'
main.cpp(122) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
main.cpp(122) : error C2143: syntax error : missing ';' before '+'
main.cpp(124) : error C2059: syntax error : '/'
main.cpp(124) : error C2001: newline in constant
main.cpp(124) : error C2015: too many characters in constant
Process terminated with status 2 (0 minutes, 6 seconds)
23 errors, 0 warnings
But what do you mean with "full compiler logging"? I find it nowhere in the compiler settings.Read my sig... ;-)
Lol thx^^Although it's hard to believe that these errors come from this file, try to create a new C - project, rename the main.cpp to main.c, add it to the project and try again.
but there are the same settings as it was in the nightly build before...Well... try removing the settings file then.
What Encoding do you have (Settings -> Editor -> General Settings -> Default Encoding...
and on the bottom status line of C::B for the current file - main.c)?
QuoteWhat Encoding do you have (Settings -> Editor -> General Settings -> Default Encoding...
UTF-7
Quoteand on the bottom status line of C::B for the current file - main.c)?
xD Sry for this stupid question, but where is that?^^ :oops:
On the bottom is: UTF-7 Line 1, Column 1, Insert, Read/Write, defualt
On the bottom is: UTF-7 Line 1, Column 1, Insert, Read/Write, defualtLooks good - that's the status line.
Try changing it to UTF-8 / Windows-1252.Aaaah - the unicode master is on-line. ;-) This is a strange issue. If you copy/paste the content of this file into a "usual" encoded one it works. Then if you choose Edit > file encoding -> UTF-7 and save the file it will stop working. The reason is that the content now looks like this (the first lines...):
+ACM-include +ADw-windows.h+AD4-
/+ACo- Declare Windows procedure +ACo-/
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM)+ADs-
/+ACo- Make the class name into a global variable +ACo-/
char szClassName+AFs- +AF0- +AD0- +ACI-CodeBlocksWindowsApp+ACIAOw-
Try changing it to UTF-8 / Windows-1252.Aaaah - the unicode master is on-line. ;-) This is a strange issue. If you copy/paste the content of this file into a "usual" encoded one it works. Then if you choose Edit > file encoding -> UTF-7 and save the file it will stop working. The reason is that the content now looks like this (the first lines...):Code+ACM-include +ADw-windows.h+AD4-
/+ACo- Declare Windows procedure +ACo-/
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM)+ADs-
/+ACo- Make the class name into a global variable +ACo-/
char szClassName+AFs- +AF0- +AD0- +ACI-CodeBlocksWindowsApp+ACIAOw-Is that how it should look like, Biplab? ...or did we find an error, possibly?!
Edit: Answering myself: Yepp, looks like proper UTF-7. But: If you close the editor and re-open it it is not detected as UTF-7. Thus you see the +AC... in C::B. That is no good.
With regards, Morten.