Can I use resource file(*.rc,*.res) in D under Win32 API?

Stewart Gordon smjg_1998 at yahoo.com
Mon Sep 14 17:45:50 PDT 2009


Sam Hu wrote:
<snip>
> int  DialogFunc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
> {
> 	switch(msg)
> 	{
> 		case WM_COMMAND:
> 		switch(LOWORD(wParam))
> 		{
> 			case IDOK:
> 			EndDialog(hwnd,1);
> 			return 1;
> 			case IDCANCEL:
> 			EndDialog(hwnd,0);
> 			return 1;
> 		}
> 		break;
> 		case WM_CLOSE:
> 			EndDialog(hwnd,0);
> 			return 1;
> 	}
<snip>

Your problem is right here: In D, switch statements must have default 
clauses of there's any chance of the value being switched not matching 
any of the switches.  If there isn't, a SwitchError is thrown at 
runtime.  Presumably, the program crashes because there's nothing 
catching the error before Windows does.

The same applies in the inner switch.

Stewart.


More information about the Digitalmars-d-learn mailing list