Newbie question about C++ text

This is a discussion on Newbie question about C++ text within the Windows Programming forums, part of the Platform Specific Boards category; Where can I put in a couple of lines that will display some black text in the window? Code: #include ...

  1. #1
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342

    Exclamation Newbie question about C++ text

    Where can I put in a couple of lines that will display some black text in the window?
    Code:
    #include <windows.h>
    
    #define ID_FILE_EXIT 9001
    #define ID_OPTIONS_SHOW 9003
    #define ID_OPTIONS_GO 9002
    #define ID_OPTIONS_CHECK 9004
    
    const char g_szClassName[] = "myWindowClass";
    
    LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
    {
            int check1;
            int check2;        
    
    	switch(Message)
    	{
    		case WM_CREATE:
    		{
    			HMENU hMenu, hSubMenu;
    			HICON hIcon, hIconSm;
    
    			hMenu = CreateMenu();
    
    			hSubMenu = CreatePopupMenu();
    			AppendMenu(hSubMenu, MF_STRING, ID_FILE_EXIT, "E&xit");
    			AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&File");
    
    			hSubMenu = CreatePopupMenu();
    			AppendMenu(hSubMenu, MF_STRING, ID_OPTIONS_SHOW, "&Show");
    			AppendMenu(hSubMenu, MF_STRING, ID_OPTIONS_GO, "&Go");
    			AppendMenu(hSubMenu, MF_STRING, ID_OPTIONS_CHECK, "&Check");
    			AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&Options");
    
    			SetMenu(hwnd, hMenu);
    
    MessageBox(hwnd, "Could not load small icon!", "Error", MB_OK | MB_ICONERROR);
    		
      }
    		break;
    		case WM_COMMAND:
    			switch(LOWORD(wParam))
    			{
    				case ID_FILE_EXIT:
    					PostMessage(hwnd, WM_CLOSE, 0, 0);
    				break;
    				case ID_OPTIONS_GO:
    					if(check1 == IDNO) {
                        MessageBox(hwnd, "You where correct.", "Done", MB_OK ); }
                        else {
                       MessageBox(hwnd, "You have failed.", "Wrong", MB_OK ); }      
    				break;
                    case ID_OPTIONS_SHOW:
                         check1 = 
    					MessageBox(hwnd, "Press the right one.", "Choose", MB_YESNO);
    				break;
    				case ID_OPTIONS_CHECK:
        char szFileName[MAX_PATH];
                        HINSTANCE hInstance = GetModuleHandle(NULL);
                        GetModuleFileName(hInstance, szFileName, 3);				
                        MessageBox(hwnd, szFileName, "Look", MB_OK);
    				break;
    			}
    		break;
    		case WM_CLOSE:
    			DestroyWindow(hwnd);
    		break;
    		case WM_DESTROY:
    			PostQuitMessage(0);
    		break;
    		default:
    			return DefWindowProc(hwnd, Message, wParam, lParam);
    	}
    	
    	return 0;
    }
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    	LPSTR lpCmdLine, int nCmdShow)
    {
    	WNDCLASSEX wc;
    	HWND hwnd;
    	MSG Msg;
    
    	wc.cbSize		 = sizeof(WNDCLASSEX);
    	wc.style		 = 0;
    	wc.lpfnWndProc	 = WndProc;
    	wc.cbClsExtra	 = 0;
    	wc.cbWndExtra	 = 0;
    	wc.hInstance	 = hInstance;
    	wc.hIcon		 = NULL;
    	wc.hCursor		 = LoadCursor(NULL, IDC_ARROW);
    	wc.hbrBackground = CreateSolidBrush(RGB(200, 200, 200));
    	wc.lpszMenuName  = NULL;
    	wc.lpszClassName = g_szClassName;
    	wc.hIconSm		 = NULL;
    
    	if(!RegisterClassEx(&wc))
    	{
    		MessageBox(NULL, "Window Registration Failed.", "Error",
    			MB_ICONEXCLAMATION | MB_OK);
    		return 0;
    	}
    
    	hwnd = CreateWindowEx(
    		WS_EX_CLIENTEDGE,
    		g_szClassName,
    		"Yarin",
    		WS_OVERLAPPEDWINDOW,
    		CW_USEDEFAULT, CW_USEDEFAULT, 290, 210,
    		NULL, NULL, hInstance, NULL);
    
    	if(hwnd == NULL)
    	{
    		MessageBox(NULL, "Window Creation Failed.", "Error",
    			MB_ICONEXCLAMATION | MB_OK);
    		return 0;
    	}
    
    	ShowWindow(hwnd, nCmdShow);
    	UpdateWindow(hwnd);
    
    	while(GetMessage(&Msg, NULL, 0, 0) > 0)
    	{
    		TranslateMessage(&Msg);
    		DispatchMessage(&Msg);
    	}
    	return Msg.wParam;
    }
    Thanks in advance, August.

  2. #2
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    Opps, sorry, what a dumb question to ask I figured it out,

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 02:59 PM
  2. How to use FTP?
    By maxorator in forum C++ Programming
    Replies: 8
    Last Post: 11-04-2005, 03:17 PM
  3. Question About Blank Lines in Text Files
    By Zildjian in forum C++ Programming
    Replies: 11
    Last Post: 10-16-2004, 05:31 PM
  4. GLenum = editbox text? (Win32/OGL question)
    By psychopath in forum Windows Programming
    Replies: 4
    Last Post: 08-27-2004, 10:23 AM
  5. Text editing related question in C++ Builder, please help.
    By Unregistered in forum Windows Programming
    Replies: 2
    Last Post: 07-02-2002, 08:53 AM

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