Click here to Skip to main content
15,913,773 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: changing font in static text control Pin
James R. Twine21-Nov-02 9:19
James R. Twine21-Nov-02 9:19 
GeneralATL & BSTR Pin
AJ12321-Nov-02 8:43
AJ12321-Nov-02 8:43 
GeneralRe: ATL & BSTR Pin
Christian Graus21-Nov-02 9:06
protectorChristian Graus21-Nov-02 9:06 
GeneralWinsock2 network events.. in a UI thread. Pin
RobJones21-Nov-02 8:23
RobJones21-Nov-02 8:23 
GeneralDetermining if the taskbar is visible or not and its height... Pin
Joan M21-Nov-02 8:06
professionalJoan M21-Nov-02 8:06 
GeneralRe: Determining if the taskbar is visible or not and its height... Pin
Paul M Watt21-Nov-02 8:14
mentorPaul M Watt21-Nov-02 8:14 
GeneralCannot Create Window Pin
Toni7821-Nov-02 7:58
Toni7821-Nov-02 7:58 
Can somebody please tell me what is wrong with my source code here because I started writing a program like I always do. Basically this is my template. When I compile it and run it, the class registrationg goes fine. But when I try to create a window I get an error saying that "Cannot create a file when it already exists". I don't get it. Why would it say that? I don't see anything wrong with my code either. I have used the same source code several times before.

#include <windows.h>

const char szMyClsName[] = "MyWndClass";

LRESULT CALLBACK WndProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam );
ATOM RegisterMyClass( HINSTANCE hInst);
BOOL InitWindow( HINSTANCE hInst, int nShowCmd);

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd )
{
MSG msg;

if( !RegisterMyClass( hInstance ) )
{
MessageBox( NULL, "Error 1", "Error", MB_OK );
return FALSE;
}
if( !InitWindow( hInstance, nShowCmd ) )
{
MessageBox( NULL, "Error 2", "Error", MB_OK );
return FALSE;
}

while( GetMessage( &msg, NULL, 0, 0 ) > 0 )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}

return msg.wParam;

} // end WinMain

ATOM RegisterMyClass( HINSTANCE hInst )
{
WNDCLASSEX wc;

wc.cbSize = sizeof( wc );
wc.style = CS_VREDRAW | CS_HREDRAW;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInst;
wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = szMyClsName;
wc.hIconSm = LoadIcon( NULL, IDI_APPLICATION );




return( RegisterClassEx( &wc ) );
}

BOOL InitWindow( HINSTANCE hInst, int nShowCmd )
{
HWND hWnd;

hWnd = CreateWindowEx( WS_EX_CLIENTEDGE, szMyClsName,
"Test",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInst,
NULL );

if( !hWnd )
return FALSE;

ShowWindow( hWnd, nShowCmd );
UpdateWindow( hWnd );

return TRUE;
}

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:
DefWindowProc( hWnd, Msg, wParam, lParam );
break;
}

return 0;
}

none
GeneralRe: Cannot Create Window Pin
Toni7822-Nov-02 9:09
Toni7822-Nov-02 9:09 
Generalvisual c++ and vt100 Pin
carmudav21-Nov-02 7:49
carmudav21-Nov-02 7:49 
GeneralRe: visual c++ and vt100 Pin
Maximilien21-Nov-02 9:14
Maximilien21-Nov-02 9:14 
GeneralRe: visual c++ and vt100 Pin
Joaquín M López Muñoz21-Nov-02 9:54
Joaquín M López Muñoz21-Nov-02 9:54 
GeneralRe: visual c++ and vt100 Pin
James R. Twine21-Nov-02 17:41
James R. Twine21-Nov-02 17:41 
GeneralRe: visual c++ and vt100 Pin
carmudav22-Nov-02 4:16
carmudav22-Nov-02 4:16 
GeneralRe: visual c++ and vt100 Pin
Maximilien22-Nov-02 4:22
Maximilien22-Nov-02 4:22 
GeneralManually create a wave file Pin
Hamza21-Nov-02 7:34
Hamza21-Nov-02 7:34 
GeneralExposing a 3rd Party ActiveX control to VBA Pin
Zac Howland21-Nov-02 6:46
Zac Howland21-Nov-02 6:46 
GeneralOpinion: Remote SQL Server Pin
clintsinger21-Nov-02 6:46
clintsinger21-Nov-02 6:46 
GeneralRe: Opinion: Remote SQL Server Pin
James R. Twine21-Nov-02 17:53
James R. Twine21-Nov-02 17:53 
QuestionWhere does MSVS 6 store its settings? Pin
User 665821-Nov-02 6:29
User 665821-Nov-02 6:29 
AnswerRe: Where does MSVS 6 store its settings? Pin
Fazlul Kabir21-Nov-02 6:43
Fazlul Kabir21-Nov-02 6:43 
GeneralThanks! Pin
User 665821-Nov-02 6:49
User 665821-Nov-02 6:49 
AnswerRe: Where does MSVS 6 store its settings? Pin
Pavel Klocek21-Nov-02 6:48
Pavel Klocek21-Nov-02 6:48 
QuestionTaskbar or not taskbar... MoveWindow and SetwindowPos behaviour changes? Pin
Joan M21-Nov-02 6:06
professionalJoan M21-Nov-02 6:06 
AnswerRe: Taskbar or not taskbar... MoveWindow and SetwindowPos behaviour changes? Pin
Paul M Watt21-Nov-02 8:19
mentorPaul M Watt21-Nov-02 8:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.