-
March 22nd, 2017, 06:49 PM
#1
C++ Create Simple Window
//The first box appears, but then it stops after that. Please help, and thanks in advanced!
Code:
#include <iostream>
#include <windows.h>
using namespace std;
const string title = "Diplomacy :: Version 0.01 :: Created by onlineone22";
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
int launch = MessageBox(NULL, "Would you like to launch Diplomacy?", title.c_str(), MB_YESNO);
if(launch == IDYES)
{
CreateWindowEx
(
0,
NULL,
title.c_str(),
WS_SYSMENU,
CW_USEDEFAULT,
CW_USEDEFAULT,
445,
445,
HWND_DESKTOP,
NULL,
hInstance,
NULL
);
}
return 0;
}
Last edited by 2kaud; March 23rd, 2017 at 03:46 AM.
Reason: Added code tags
-
March 23rd, 2017, 02:59 AM
#2
Re: C++ Create Simple Window
Did you try to debug your code?
Anyway, it looks like you just return from the WinMain after creating (or not creating) the window...
Victor Nijegorodov
-
March 29th, 2017, 08:06 AM
#3
You can do that by sfml graphics, its so simple:
Just follow this syntax:
RenderWindow windowname(Videomode(height,width), "Name to appear on the top")
But for that you need to have sfml libraries on your computer.
[Multiple posts merged into 1 post]
Last edited by 2kaud; March 29th, 2017 at 08:28 AM.
Reason: Posts merged
-
March 29th, 2017, 08:27 AM
#4
Re: C++ Create Simple Window
Do it like this :
Code:
Code:
#include<iostream>
#include<SFML/Graphics.hpp>
using namespace std;
using namespace sf;
int main()
{
cout << "Would you like to launch diplomacy?" << endl;
char YESNO = '/0';
do
{
RenderWindow window(VideoMode(445, 445), "Diplomacy :: version 0.01 :: Created by onlineone22);
window.setFrameratelimit(60);
window.clear();
window.display();
}while (YESNO == IDYES)
return 0;
}
Last edited by A_Singh; April 1st, 2017 at 09:05 AM.
Reason: Added code tags
-
March 29th, 2017, 08:36 AM
#5
Re: C++ Create Simple Window
As this simple test program doesn't contain the required sfml #include statement, I doubt it will compile. Also the YESNO variable isn't changed within the loop and the while condition is an assignment rather than an equality test.
Last edited by 2kaud; March 29th, 2017 at 08:40 AM.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
March 29th, 2017, 08:39 AM
#6
Re: C++ Create Simple Window
-
March 29th, 2017, 08:43 AM
#7
Re: C++ Create Simple Window
-
April 6th, 2017, 06:27 AM
#8
Re: C++ Create Simple Window
CreateWindowEx just creates a window. To make it be alive and respond to user events, keyboard or mouse, you need to implement window procedure and spin up a message loop.
Best regards,
Igor
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|