Results 1 to 16 of 16

Thread: Geeze, you serious. That's illegal???

  1. #1

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    For which compiler? MSVC, Borland, Other?

    By start do you mean I am a newbie and I dont know what to do with C++?
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Just To Start An App:
    Code:
    1. open visual c++
    2. File > New
    3. Click Projects tab
    4. click Win32 Application and give it a name
    5. click finish
    6. click the File View Tab on TreeView
    7. go to File > New
    8. in the first tab Click C++ Source File and name it
    9. Copy and paste the code in the new file
    10. right click the Header folder and add Windows.h
    11. click execute
    
    #include <windows.h>
    LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM);
    char szWinNamw[] = "MyWin";
    int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst,
    				LPSTR kposzArgs, int nWinMode)
    
    
        {
        	HWND hwnd;
        	MSG msg;
        	WNDCLASSEX wcl;
        	wcl.cbSize = sizeof(WNDCLASSEX);
        	wcl.hInstance = hThisInst;
        	wcl.lpszClassName = "My Window";
        	wcl.lpfnWndProc = WindowFunc;
        	wcl.style = 0;
        	wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
        	wcl.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
        	wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
        	wcl.lpszMenuName = NULL;
        	wcl.cbClsExtra = 0;
        	wcl.cbWndExtra = 0;
        	wcl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
        	if(!RegisterClassEx(&wcl)) return 0;
        	hwnd = CreateWindow(
        		"My Window",
        		"Skeleton Window",
        		WS_OVERLAPPEDWINDOW,
        		CW_USEDEFAULT,
        		CW_USEDEFAULT,
        		CW_USEDEFAULT,
        		CW_USEDEFAULT,
        		HWND_DESKTOP,
        		NULL,
        		hThisInst,
        		NULL
        		);
        	ShowWindow(hwnd, nWinMode);
        	UpdateWindow(hwnd);
        	while(GetMessage(&msg, NULL, 0, 0))
    
    
            	{
            		TranslateMessage(&msg);
            		DispatchMessage(&msg);
            	}
            	return msg.wParam;
        }
        LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message,
        							WPARAM wParam, LPARAM lParam)
    
    
            {
    
    
                	switch(message)	{
                	case WM_DESTROY:
                		PostQuitMessage(0);
                		break;
                	default:
                		return DefWindowProc(hwnd, message, wParam, lParam);
                	}
                	return 0;
            }
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    That's for Windows, if you didn't know. If you're really new to C++, this may help (use Win32 Console Application instead):
    Code:
    #include <iostream.h>
    
    int main() {
        cout << "Hello World!" << endl;
        return 0;
    }
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4
    Guest
    Ok, one, there are hundreds of other threads centered on this topic. Please look for them instead of posting the same question (this thread proves we need a FAQ). Two, please do not post subject titles that are not related to the question (unless its in the chit chat forum, anything goes in there, well not anything, well you know what i mean).

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    anything goes in there, well not anything, well you know what i mean
    Hmmm...
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    Unhappy Thanx for the help

    Thanx for all the help, I am trying to get used to C++ without MFC.

    Would anyone be able to post any info, website links, code, apps. Anything to do with C++ without using MFC, for Windows.

    Thanks
    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

  7. #7
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    I got another one for you all.

    I have this code

    #include <windows.h>
    LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM);
    char szWinNamw[] = "MyWin";

    int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst,
    LPSTR kposzArgs, int nWinMode)
    {
    HWND hwnd;
    HWND hwndStatic;
    HWND hwndButton;
    MSG msg;
    WNDCLASSEX wcl;
    wcl.cbSize = sizeof(WNDCLASSEX);
    wcl.hInstance = hThisInst;
    wcl.lpszClassName = "My Window";
    wcl.lpfnWndProc = WindowFunc;
    wcl.style = 0;
    wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wcl.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
    wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
    wcl.lpszMenuName = NULL;
    wcl.cbClsExtra = 0;
    wcl.cbWndExtra = 0;
    wcl.hbrBackground = (HBRUSH) GetStockObject(GRAY_BRUSH);
    if(!RegisterClassEx(&wcl)) return 0;
    hwnd = CreateWindow(
    "My Window",
    "Blank Form",
    WS_OVERLAPPEDWINDOW,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    300,
    CW_USEDEFAULT,
    HWND_DESKTOP,
    NULL,
    hThisInst,
    NULL
    );
    hwndStatic = CreateWindow(
    "Static",
    "Title Label",
    WS_CHILD,
    100,
    50,
    100,
    20,
    hwnd,
    NULL,
    hThisInst,
    NULL
    );
    hwndButton = CreateWindow(
    "Button",
    "Press Me",
    WS_CHILD,
    100,
    100,
    100,
    50,
    hwnd,
    NULL,
    hThisInst,
    NULL
    );
    ShowWindow(hwnd, nWinMode);
    ShowWindow(hwndStatic, SW_SHOWNORMAL);
    ShowWindow(hwndButton, SW_NORMAL);
    UpdateWindow(hwnd);
    while(GetMessage(&msg, NULL, 0, 0))


    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    return msg.wParam;
    }
    LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message,
    WPARAM wParam, LPARAM lParam)
    {
    switch(message) {
    case WM_DESTROY:
    PostQuitMessage(0);
    break;
    default:
    return DefWindowProc(hwnd, message, wParam, lParam);
    }

    }


    This is a variation of Vlakto's, how can I receive a message for my own button?
    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

  8. #8
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Use code tags!
    Harry.

    "From one thing, know ten thousand things."

  9. #9
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    Umm, what do you mean by tags??

    I'm not to sure, but if you mean labeling, then I'm sorry about the mess, if you don't then please explain.
    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

  10. #10
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    use [code][/code] tags so it looks like this:

    Code:
    #include <windows.h> 
    LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM); 
    char szWinNamw[] = "MyWin"; 
    
    int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst, 
    				   LPSTR kposzArgs, int nWinMode) 
    { 
    	HWND hwnd; 
    	HWND hwndStatic; 
    	HWND hwndButton; 
    	MSG msg; 
    	WNDCLASSEX wcl; 
    	wcl.cbSize = sizeof(WNDCLASSEX); 
    	wcl.hInstance = hThisInst; 
    	wcl.lpszClassName = "My Window"; 
    	wcl.lpfnWndProc = WindowFunc; 
    	wcl.style = 0; 
    	wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION); 
    	wcl.hIconSm = LoadIcon(NULL, IDI_WINLOGO); 
    	wcl.hCursor = LoadCursor(NULL, IDC_ARROW); 
    	wcl.lpszMenuName = NULL; 
    	wcl.cbClsExtra = 0; 
    	wcl.cbWndExtra = 0; 
    	wcl.hbrBackground = (HBRUSH) GetStockObject(GRAY_BRUSH); 
    	if(!RegisterClassEx(&wcl)) return 0; 
    	hwnd = CreateWindow( 
    		"My Window", 
    		"Blank Form", 
    		WS_OVERLAPPEDWINDOW, 
    		CW_USEDEFAULT, 
    		CW_USEDEFAULT, 
    		300, 
    		CW_USEDEFAULT, 
    		HWND_DESKTOP, 
    		NULL, 
    		hThisInst, 
    		NULL 
    		); 
    	hwndStatic = CreateWindow( 
    		"Static", 
    		"Title Label", 
    		WS_CHILD, 
    		100, 
    		50, 
    		100, 
    		20, 
    		hwnd, 
    		NULL, 
    		hThisInst, 
    		NULL 
    		); 
    	hwndButton = CreateWindow( 
    		"Button", 
    		"Press Me", 
    		WS_CHILD, 
    		100, 
    		100, 
    		100, 
    		50, 
    		hwnd, 
    		NULL, 
    		hThisInst, 
    		NULL 
    		); 
    	ShowWindow(hwnd, nWinMode); 
    	ShowWindow(hwndStatic, SW_SHOWNORMAL); 
    	ShowWindow(hwndButton, SW_NORMAL); 
    	UpdateWindow(hwnd); 
    	while(GetMessage(&msg, NULL, 0, 0)) 
    		
    		
    	{ 
    		TranslateMessage(&msg); 
    		DispatchMessage(&msg); 
    	} 
    	return msg.wParam; 
    } 
    LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, 
    							WPARAM wParam, LPARAM lParam) 
    { 
    	switch(message) { 
    	case WM_DESTROY: 
    		PostQuitMessage(0); 
    		break; 
    	default: 
    		return DefWindowProc(hwnd, message, wParam, lParam); 
    	} 
    	
    }
    In case you're wondering I didn't go through all that indenting it, I just pasted it into VC++, highlighted it and pressed Alt-F8.
    Harry.

    "From one thing, know ten thousand things."

  11. #11
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    Unhappy Thanx for the help

    I'm not being rude or anything, but. I pretty much new that, and also. I NEED HELP. I've gotten a bit further. I have this now.

    Notice the pretty code tags:
    Code:
    #include <windows.h>
    LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM);
    char szWinNamw[] = "MyWin";
    
    int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst,
    				LPSTR kposzArgs, int nWinMode)
     {	
        	HWND hwnd;
    		HWND hwndStatic;
    		HWND hwndButton;
        	MSG msg;
        	WNDCLASSEX wcl;
        	wcl.cbSize = sizeof(WNDCLASSEX);
        	wcl.hInstance = hThisInst;
        	wcl.lpszClassName = "My Window";
        	wcl.lpfnWndProc = WindowFunc;
        	wcl.style = 0;
        	wcl.hIcon = LoadIcon(NULL, "sire.ico");
        	wcl.hIconSm = LoadIcon(NULL, "sire.ico");
        	wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
        	wcl.lpszMenuName = NULL;
        	wcl.cbClsExtra = 0;
        	wcl.cbWndExtra = 0;
        	wcl.hbrBackground = (HBRUSH) GetStockObject(GRAY_BRUSH);
        	if(!RegisterClassEx(&wcl)) return 0;
        	hwnd = CreateWindow(
        		"My Window",
        		"Blank Form",
        		WS_OVERLAPPEDWINDOW,
        		CW_USEDEFAULT,
        		CW_USEDEFAULT,
        		300,
        		CW_USEDEFAULT,
        		HWND_DESKTOP,
        		NULL,
        		hThisInst,
        		NULL
        		);
    		hwndStatic = CreateWindow( 
    			"Static",
    			"Title Label",
    			WS_CHILD,
    			100, 
    			50, 
    			100, 
    			20,
    			hwnd, 
    			NULL,
    			hThisInst,
    			NULL
    			);
    		hwndButton = CreateWindow(
    			"Button",
    			"Press Me",
    			WS_CHILD,
    			100,
    			100,
    			100,
    			50,
    			hwnd,
    			NULL,
    			hThisInst,
    			NULL
    			);
        	ShowWindow(hwnd, nWinMode);
    		ShowWindow(hwndStatic, SW_SHOWNORMAL);
    		ShowWindow(hwndButton, SW_NORMAL);
        	UpdateWindow(hwnd);
        	while(GetMessage(&msg, NULL, 0, 0))
    
    
            	{
            		TranslateMessage(&msg);
            		DispatchMessage(&msg);
            	}
            	return msg.wParam;
        }
        LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message,
        							WPARAM wParam, LPARAM lParam)
    	{	
                	switch(message)	{
                	case WM_DESTROY:
                		PostQuitMessage(0);
                		break;
    				case WM_LBUTTONDOWN:
    					MessageBox(hwnd, "Button Pressed", "Press", MB_OK);
    					break;
    				case WM_COMMAND:
    					HWND hwndButton;
    					int idButton;
    					
    					hwndButton = (HWND) lParam;
    					idButton = (int) LOWORD(wParam);
    
    					if (idButton = BN_CLICKED){
    						MessageBox( hwnd, "Button Clicked", "Pressed", MB_OK); }
    					else if (idButton = BN_DOUBLECLICKED){
    						MessageBox( hwnd, "Double Clicked", "Pressed", MB_OK); }
    					break;
    				default:
                		return DefWindowProc(hwnd, message, wParam, lParam);
                	}
          }
    How do I change the background to look normal???
    How use the icon properly. It's called sire.ico
    What else can I do, to make it look more normal??
    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

  12. #12
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    If you knew how to use code tags before, why didn't you use them? That's all I said.


    Anyway what's 'normal'? Do you mean like VB's forms? If you want to make the background a certain colour or pattern then you can use GDI graphics to do it... I think you might just have to select in a new brush into the DC for the inside of the windows, I'm not sure.

    I'm not sure you can load an icon like that, I think you need to put it in a resource file, give it an identifier and compile it into your exe.
    Harry.

    "From one thing, know ten thousand things."

  13. #13
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Normally you'd put the icon into a resource but you can load it from disk. The LoadImage function supports both.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  14. #14
    Guest
    Personally, I perfer to only use Showwindow on the Main window. The rest of the child windows are shown via the WS_VISIBLE style.

  15. #15
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    Thanx for all the Advice

    Megatron: I'm not to sure what you mean, how can I not, use ShowWindow, and get the window to show. By this I mean a button or something.

    Parksie: Your help also great, actually it wasn't great at all, now I think of it. It was perfect. Thanx!!

    HarryW: Umm, for you question, I wasn't too sure on actuall Scripting tags, but now I know. Also, I found a way to display the normal colour.

    Code:
    wcl.hbrBackground = (HBRUSH) COLOR_APPWORKSPACE;
    But thanks anyway.

    Keep posting more if you want. Anybody, if it even remotley relates to Win32 C++, then just post it. It'll get your posts up

    Thanxs again.
    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

  16. #16
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    In order for a window to be automatically visible, you need to specify the WS_VISIBLE style. If you don't then it will be hidden and require ShowWindow.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width