Click here to Skip to main content
15,886,572 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Sir, I am a beginner in windows programming. I have created a dialog box in Win32 API. My dialog box consists of only one push button named "Copy" for IDOK.I have not enabled the maximize and minimize buttons in my dialog box but has close button(not push button with an IDCLOSE) I mean the close button seen in the top right corner of the dialogbox like this [X].

I have added all the resources for creating the dialogbox and my dialog box has created successfully.But now I have coded a without argument & without return type function on a seperate file named "open". My wish is to call the function(To make a function call) on clicking the "Copy" button so I did this,

C++
case ID_HELP_COPY:
			{
				DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1), hWnd, Help);
			case IDOK:
			{
				open();
				break;
			}
			}


There were no errors and warnings in my executable.And by clicking the "Copy" button the file has created successfully.
problem:
It also creates file on closing the dialog without clicking the copy button i.e. The top right corner button
I have added a break statement but it is of no use.

Have I missed anything?

Kindly help me with this sir.

Thank you
Posted
Updated 12-Jan-16 4:52am
v2
Comments
Sergey Alexandrovich Kryukov 12-Jan-16 10:55am    
Your code sample taken out of context is not helpful enough to solve your problem. Use the debugger to find out where the problem is. It should be quite simple.
—SA
[no name] 12-Jan-16 11:47am    
Sir, Thank you for your kind comment.My problem has solved.
But to acquire some knowledge, do you mean to set break points?
Sergey Alexandrovich Kryukov 12-Jan-16 12:07pm    
Great, my congratulations. You are very welcome.

Break points? Sure, but this is a basic debugging technique. Typically, this is what you start with. For successful development, you should better learn nearly of them. It's pretty easy to do but most helpful.

Good luck, call again.

—SA
[no name] 12-Jan-16 12:54pm    
Sir, I should sincerely Thank you for your kind suggestion

1 solution

Quote:
DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1), hWnd, Help);
case IDOK:
{
open();
break;
}

Should be (I guess)
C++
if ( DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1), hWnd, Help) == IDOK )
{
  open();
}
break;
 
Share this answer
 
Comments
[no name] 12-Jan-16 11:41am    
Sir, Thank you for your kind and quick solution.
It worked for me.
CPallini 12-Jan-16 11:52am    
You are welcome.
Sergey Alexandrovich Kryukov 12-Jan-16 12:08pm    
5ed.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900