|
David, I don't really understand the 5-8 argument part. I solved the other one.
"To save confusion, you might want to use CW_USEDEFAULT or 0 for arguments 5-8."
Andrew McIntyre
|
|
|
|
|
See here and here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
You mean you don't want to see the caption bar of the window, and the border of the window?
|
|
|
|
|
 This is a disaster. Here is the entire source code for the win32.
<br />
#include <windows.h><br />
<br />
const char g_szClassName[] = "My Project";<br />
<br />
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)<br />
{<br />
switch(msg)<br />
{<br />
case WM_CLOSE:<br />
DestroyWindow(hwnd);<br />
break;<br />
case WM_DESTROY:<br />
PostQuitMessage(0);<br />
break;<br />
default:<br />
return DefWindowProc(hwnd, msg, wParam, lParam);<br />
}<br />
return 0;<br />
}<br />
<br />
<br />
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,<br />
LPSTR lpCmdLine, int nCmdShow)<br />
{<br />
WNDCLASSEX wc;<br />
HWND hwnd;<br />
MSG Msg;<br />
<br />
<br />
wc.cbSize = sizeof(WNDCLASSEX);<br />
wc.style = 0;<br />
wc.lpfnWndProc = WndProc;<br />
wc.cbClsExtra = 0;<br />
wc.cbWndExtra = 0;<br />
wc.hInstance = hInstance;<br />
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);<br />
wc.hCursor = LoadCursor(NULL, IDC_ARROW);<br />
wc.hbrBackground = (HBRUSH)GetStockObject ( BLACK_BRUSH );<br />
wc.lpszMenuName = 0;<br />
wc.lpszClassName = g_szClassName;<br />
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);<br />
<br />
<br />
if(!RegisterClassEx(&wc))<br />
{<br />
MessageBox(NULL, "Window Registration Failed!", "iWorld",<br />
MB_ICONEXCLAMATION | MB_OK);<br />
return 0;<br />
}<br />
<br />
<br />
hwnd = CreateWindowEx(<br />
WS_EX_CLIENTEDGE,<br />
g_szClassName,<br />
"My Project",<br />
WS_POPUP,<br />
SW_MAXIMIZE. <br />
NULL, NULL, hInstance, NULL);<br />
<br />
<br />
if(hwnd == NULL)<br />
{<br />
MessageBox(NULL, "Window Creation Failed!", "Error!",<br />
MB_ICONEXCLAMATION | MB_OK);<br />
return 0;<br />
}<br />
<br />
<br />
<br />
<br />
ShowWindow(hwnd, nCmdShow);<br />
UpdateWindow(hwnd);<br />
<br />
<br />
while(GetMessage(&Msg, NULL, 0, 0) > 0)<br />
{<br />
TranslateMessage(&Msg);<br />
DispatchMessage(&Msg);<br />
}<br />
return Msg.wParam;<br />
}<br />
<br />
Andrew McIntyre
|
|
|
|
|
MrMcIntyre wrote: hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_szClassName,
"My Project",
WS_POPUP,
SW_MAXIMIZE. <<---
NULL, NULL, hInstance, NULL);
Surely this does not compile for you.
It should be:
hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, g_szClassName, "My Project", WS_POPUP,
0, 0, 0, 0,
(HWND) NULL, (HMENU) NULL, hInstance, NULL);
MrMcIntyre wrote: ShowWindow(hwnd, nCmdShow);
ShowWindow(hwnd, SW_MAXIMIZE);
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
David Thank you so much. Its much appreciated.
--Andrew
Andrew McIntyre
|
|
|
|
|
Is there a reason you posted the same question later, after this one already got replies? Twice within a minute... That's being unlucky, and a technical issue.
Here's an article that makes a window be fullscreen:
Gribble1 - CWnd goes full screen[^]
It's based on MFC - but if you have the skills to make a virtual world program, I'm sure you can decode it. MFC is a very thin wrapper after all.
Good luck,
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Hi,
Is there any way I can get rid of the white border in full screen it makes the application look bad.
Andrew McIntyre
|
|
|
|
|
What white border?
See if the dimensions you are using match the screen size, and make sure you are drawing all the way to the edge.
Those are simple ideas, but the only ones I have!
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
I am new to this forum,
Please refer to the c++ program and the output below. I understand the program but I have a small doubt regarding the output of the program. pls help.
# include <iostream.h>
# include <conio.h>
void main ( )
{
int x[5] = {1,2,3,4,5}, y [5] = {5,4,3,2,1},
result [5] = { 0,0,0,0,0 };
int i= 0,j=0;
clrscr();
while (i++ < 5)
{
cout<<i<<"\n";
result [i] = x [i] + y [i];
}
cout <<"\n The contents of the array are: \n";
do
{
cout << "\t" << x [j];
cout<< "\t" << y [j];
cout<<"\t"<< result [j]<<"\n";
j++;
} while (j<5);
getch ( );
}
While executing the output of the program is:-
1 -1 0
2 4 -2
3 3 0
4 2 2
5 1 4
How i get the output as 1 -1 0 in the first row especially I presume the output should be 1 5 0 in the first row. Please help.
thanks
|
|
|
|
|
Your computations go into result[1..5] using x[1..5] and y[1..5]. Those arrays are sized at [0..4] so you are exceeding the bounds of the arrays. Your printout uses [0..4] which is correct.
|
|
|
|
|
Thankyou sir but pls explain how I got the first row output especially the -1 in the middle. I need the same array dimension because its given that in a text book.
|
|
|
|
|
You exceeded the bounds of the array definition, what data you fetch or corrupt when you do that is up to the "memory alignment gods". Fix the program as suggested so that you do not exceed the array boundaries and you will stop getting wierd output.
|
|
|
|
|
Thank you sir,
How to fix the problem where I need to make changes?
|
|
|
|
|
David Crow gave you the answer, have you tried it.
|
|
|
|
|
Thank you sir,
You told me to fix the size. How to change because its been initialized. Mr crow told to increment later in the loop. But its should be there in the while part itself. If so how to rectify by changing the array size.
|
|
|
|
|
venkatasu wrote: You told me to fix the size.
Nothing was mentioned about changing the size of the array. Arrays are 0 -based.
venkatasu wrote: Mr crow told to increment later in the loop. But its should be there in the while part itself.
I did not say to move the increment statement outside of the while() loop. What part of
while (i < 5)
{
cout << i << endl;
result[i] = x[i] + y[i];
i++;
} troubles you?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thank you sir, I understood you told me to increment inside the loop. But they want me to retain the i++ at the begining of the while loop if so what to do.
|
|
|
|
|
venkatasu wrote: But they want me to retain the i++ at the begining of the while loop...
I will refrain from saying (to "they") what is really on my mind. If you insist on keeping it, put a pillow on your desk else your forehead will soon hurt.
Why is it okay for the second loop to increment its control variable correctly?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
As long as you insist that you don't need any code modifications, you will get nowhere with changing the array dimensions.
You are computing and filling in array entries 1 through 5
You are printing out array entries 0 through 4
That is *bad code*, changing array dimensions will not affect this basic flaw.
David Crow has given you two excellent hints (nobody is going to write the program for you). I gave you hints on the fundamental problem. Now it is your turn to demonstrate that you have read, understood, and found the problem yourself. David and I have already passed this course.
I'm done now.
|
|
|
|
|
Oh I am sorry if I have troubled you as I am a newbie please excuse me and guide me as I am confused and newbie.
Thanks a lot sir
|
|
|
|
|
It's one thing to be new and willing to change/explore, it's altogether different to be new and stubborn. By insisting on the latter, you're not going to advance very far.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
venkatasu wrote: while (i++ < 5)
Increment i at the bottom of the while() loop.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Sir
I need the same program. Its given in a text book. I want to know how I got the -1 in middle of the first row.
|
|
|
|
|
venkatasu wrote: Its given in a text book. I want to know how I got the -1 in middle of the first row.
I've given you the answer. Implement it and you're code will work as expected.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|