Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

demonrealms

WinAPI Problems

This topic is 5459 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I''m running into a serious problem with this board. It used to be helpful but now it''s just ignoring me completly. Why? I''m starting to go insane with this problem. I can''t get it to create the files I tell it to in the textbox. I have a dialog box with a textbox named IDC_TEXT and a button named: IDC_CREATE2. But when I click the create button in my dialog, it doesn''t create my text file that are in the textbox. I type ion test.txt then click create, And nothing happens. Why? Heres the source code for the button if needed. Anything else that''s needed please tell me.
BOOL CALLBACK ToolDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
    switch(Message)
	{
		case WM_COMMAND:
			switch(LOWORD(wParam))
			{
				case IDC_CREATE2:
					{
						int nTimes = 1;
						int len = GetWindowTextLength(GetDlgItem(g_hToolbar, IDC_TEXT));
						char* buf;
						buf = (char*)GlobalAlloc(GPTR, len + 1);
						ofstream create22( IDC_TEXT );
						create22.close();
						break;
					}
				case IDC_CREATE3:
					{
						ofstream file001( IDC_DIR );
						file001.close();
						break;
					}
				case IDC_OPTION6:
					{
						dis2=(dis2 - 1);
						ShowWindow(g_hToolbar2, SW_HIDE);
						break;
					}
			}
		break;
		default:
			return FALSE;
	}
	return TRUE;

}
It''s not to long. Thanks in advance, demonrealms

Share this post


Link to post
Share on other sites
Advertisement
Nothing happened. Thanks for trying though. I'm really getting sick of looking through these lines of code though. Can anyone give me code on how this works? Nothing large, Just how they'd put the code above? Or any other idea's? Thanks.

[edited by - demonrealms on October 10, 2003 6:43:01 PM]

[edited by - demonrealms on October 10, 2003 6:48:32 PM]

Share this post


Link to post
Share on other sites
normally we don''t just code someone else''s code, we will help you to do it your self, but I''m feeling happy today, so here, this works for me:


#include <windows.h>
#include <stdio.h>
#include "resource.h"

LRESULT CALLBACK WndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch(msg)
{
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_CREATE2:
{
int len = GetWindowTextLength(GetDlgItem(hWnd,IDC_TEXT)) + 1;
char *string = new char[len];
GetDlgItemText(hWnd,IDC_TEXT,string,len);

FILE *pFile = fopen(string,"wb");
fprintf(pFile,"Hello, world\n");
fclose(pFile);

delete [] string;
}
break;
}
break;
case WM_CLOSE:
EndDialog(hWnd,0);
break;
}
return 0;
}

int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,char *cmdLine,int showCmd)
{
DialogBox(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),0,(DLGPROC)WndProc);
return 0;
}


My Site

Share this post


Link to post
Share on other sites
Thank you! It worked. *sigh* I''m just so happy. Now I understand how you work with these Dialog controls and can move on. Yay! Thanks a lot man. I appreciate it!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!