|
What do you see when you open the file manually?
|
|
|
|
|
Hi
I can read in wide string. But I can not read numbers. I can get string by using "read" function. But I can not get anything back using operator ">>".
Thanks,
|
|
|
|
|
I suspect the numbers as you mention are stored as strings in your file.
If it is stored as numbers, it should not make any sense when you open the file manually.
|
|
|
|
|
Yes, I saved them as numbers not string. It tried to read a binary file which has string and numbers. The string was saved as string and numbers is as numbers (not string).
Why wifstream does not read number only string?
How can I correct them?
Thanks,
modified on Monday, November 2, 2009 11:56 AM
|
|
|
|
|
Hi again,
Can someone be helpful and show me a link or a piece of code that allows me to insert into my code so when the user clicks the X button at the top of the client so a message box appear and says "Are you sure you want to exit" along with the event.
Thanks
Andrew McIntyre
|
|
|
|
|
Handle the WM_CLOSE[^] message for the window.
You can put your message box in this handler.
|
|
|
|
|
switch (message)<br />
{<br />
case WM_CLOSE:<br />
MessageBox(NULL, "Are you sure you want to exit?", "Exit", MB_YESNO | MB_ICONEXCLAMATION);<br />
DestroyWindow(hwnd);<br />
break;<br />
}
Can someone help me find a missing identifier and show me where I have to put it.
Thanks
Andrew McIntyre
modified on Sunday, November 1, 2009 3:39 PM
|
|
|
|
|
case WM_CLOSE:
if (MB_YES == MessageBox(hwnd, _T("Are you sure you want to exit?"), _T("Confirmation"), MB_YESNO))
DestroyWindow(hwnd);
return 0;
For MFC it could look like this -
void CYourClass::OnClose()
{
if (MB_YES == MessageBox(hwnd, _T("Are you sure you want to exit?"), _T("Confirmation"), MB_YESNO))
DestroyWindow(hwnd);
}
|
|
|
|
|
Hi. I think I've done something wrong somewhere.
#include <windows.h><br />
<br />
#define WINDOW_WIDTH 1040<br />
#define WINDOW_HEIGHT 750<br />
<br />
const char lpClassName[] = "My Project";<br />
HWND mainWindow;<br />
<br />
LRESULT CALLBACK WindowEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);<br />
<br />
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)<br />
{<br />
WNDCLASSEX wc;<br />
wc.style = CS_VREDRAW | CS_HREDRAW;<br />
wc.lpszMenuName = NULL;<br />
wc.lpszClassName = lpClassName;<br />
wc.lpfnWndProc = WindowEvent;<br />
wc.hInstance = hInstance;<br />
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);<br />
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);<br />
wc.hCursor = LoadCursor(NULL, IDC_ARROW);<br />
wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);<br />
wc.cbWndExtra = 0;<br />
wc.cbSize = sizeof(wc);<br />
wc.cbClsExtra = 0;<br />
<br />
RegisterClassEx(&wc);<br />
<br />
mainWindow = CreateWindowEx(<br />
NULL,<br />
lpClassName,<br />
"My Project",<br />
WS_OVERLAPPEDWINDOW | WS_VISIBLE,<br />
(GetSystemMetrics(SM_CXSCREEN) / 2) - (WINDOW_WIDTH / 2),<br />
(GetSystemMetrics(SM_CYSCREEN) / 2) - (WINDOW_HEIGHT / 2),<br />
WINDOW_WIDTH,<br />
WINDOW_HEIGHT,<br />
NULL,<br />
NULL,<br />
hInstance,<br />
NULL<br />
);<br />
<br />
if (!mainWindow)<br />
return 0;<br />
<br />
UpdateWindow(mainWindow);<br />
<br />
MSG msg;<br />
<br />
while (1)<br />
{<br />
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))<br />
{<br />
if (msg.message == WM_QUIT)<br />
TranslateMessage(&msg);<br />
DispatchMessage(&msg);<br />
}<br />
}<br />
return (int) msg.wParam;<br />
}<br />
LRESULT CALLBACK WindowEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)<br />
{<br />
switch (message)<br />
{<br />
case WM_CLOSE:<br />
if (MB_YES == MessageBox(hwnd, _T("Are you sure you want to exit?"), _T("Confirmation"), MB_YESNO))<br />
DestroyWindow(hwnd);<br />
<br />
return 0;<br />
break;<br />
}<br />
return DefWindowProc(hWnd, message, wParam, lParam);<br />
}
Andrew McIntyre
|
|
|
|
|
You really must do this on your own.
Change the first parameter of MessageBox from hwnd to hWnd .
|
|
|
|
|
I got three compile errors:
'MB_YES' : undeclared identifier
'_T': identifier not found
'_T': identifier not found
Andrew McIntyre
|
|
|
|
|
Can someone help me with those errors.
Please
Andrew McIntyre
|
|
|
|
|
MessageBox Function()[^]
Look under the return value section for what you're looking for.
_T("") is a text macro, you can try TEXT("") if it's not defined. If both are undefined, just don't use it. (put function("text here") instead of function(_T("text here")))
|
|
|
|
|
MrMcIntyre wrote: if (MB_YES == MessageBox(hwnd, _T("Are you sure you want to exit?"), _T("Confirmation"), MB_YESNO))
DestroyWindow(hwnd);
hwnd has not been declared.
"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
|
|
|
|
|
Hi. I fixed the other 2 errors just one last error to fix.
if (MB_YES == MessageBox(hWnd, ("Are you sure you want to exit?"), ("Confirmation"), MB_YESNO))<br />
DestroyWindow(hWnd); <br />
else <br />
return 0;
The error was:
'MB_YES' : undeclared identifier
Andrew McIntyre
|
|
|
|
|
Read the docs for MessageBox(), specifically the return value
"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
|
|
|
|
|
Can you create a quick snippet of how the code should look like.
Andrew McIntyre
modified on Monday, November 2, 2009 5:17 PM
|
|
|
|
|
MrMcIntyre wrote: That is the right code...
Andrew, if it was right the compiler would not be complaining.
MrMcIntyre wrote: ...its just the undeclared identifer I need fixed.
What is it that you think MessageBox() needs to return?
"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
|
|
|
|
|
Where can I find the documentation from?
Andrew McIntyre
|
|
|
|
|
Its ok. I fixed it. You guy's are the best. Thanks
Andrew McIntyre
|
|
|
|
|
Other than the link I provided, I'm not sure.
"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
|
|
|
|
|
i am new in c++ MFC.i want to make a simple calculator using mfc with user interface . may i have a ready source code from u friend or any suggesion? please send me full source code.i want to analyse it. plzzzzzzzzzzzzzz........
|
|
|
|
|
You should try to do it on your own.
Such questions are not appreciated in the forums.
You will never get what you're looking for if you post such questions.
There are many articles and resources available on the internet.
Search and read them and a simple calculator is a fairly easy task.
All the best.
|
|
|
|
|
goutom roy wrote: i am new in c++ MFC.i want to make a simple calculator using mfc with user interface . may i have a ready source code from u friend or any suggesion? please send me full source code.
Why do you stop on requesting the full source code? Why should you, smart developer, accomplish the boring task of compilation? Ask for an already compiled, full functional application, instead! I can even help you on this: if you give me your e-mail address then I'm going to sent you the binaries of the Windows Calculator.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
goutom roy wrote: .i want to make...may i have a ready source code
Those two statements are contradictory. If we give it to you, you've not made it. How would that look if you went around bragging to all your friends that you made this wonderful calculator when in fact, you simply just took the code and added your name to it?
"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
|
|
|
|