www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Windows Resources

reply "Prudence" <Pursuit Happyness.All> writes:
I'm trying to create a win32 window. I coped the code pretty much 
directly from msdn:

	MSG msg;
		BOOL bRet;
		WNDCLASS wc;

		// Register the window class for the main window.

		if (!hPrevInstance)
		{
			wc.style = 0;
			wc.lpfnWndProc = cast(WNDPROC)&WndProc;
			wc.cbClsExtra = 0;
			wc.cbWndExtra = 0;
			wc.hInstance = hInstance;
			//wc.hIcon = LoadIcon(cast(HINSTANCE) NULL, IDI_APPLICATION);
			//wc.hCursor = LoadCursor(cast(HINSTANCE) NULL, IDC_ARROW);
			wc.hIcon = NULL;
			wc.hCursor = NULL;
			wc.hbrBackground = GetStockObject(WHITE_BRUSH);
			wc.lpszMenuName =  "MainMenu";
			wc.lpszClassName = "MainWndClass";

			if (!RegisterClass(&wc))
				return FALSE;
		}

		// Create the main window.
		hwndMain = CreateWindow("MainWndClass", "Sample",
								WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
								CW_USEDEFAULT, CW_USEDEFAULT, cast(HWND) NULL,
								cast(HMENU) NULL, hInstance, cast(LPVOID) NULL);
		if (!hwndMain)
		{
			auto x = GetLastError();
			return FALSE;
		}


x is 1812 = ERROR_RESOURCE_DATA_NOT_FOUND

That's about as far as I can get. (what resource data? Where I do 
put it? How, who, when?)
Sep 05 2015
next sibling parent "BBasile" <bb.temp gmx.com> writes:
On Saturday, 5 September 2015 at 19:06:15 UTC, Prudence wrote:
[...]
Check this file https://github.com/D-Programming-Language/dmd/blob/master/samples/winsamp.d ,it's distributed with your D setup.
Sep 05 2015
prev sibling next sibling parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
On Saturday, 5 September 2015 at 19:06:15 UTC, Prudence wrote:
 That's about as far as I can get. (what resource data? Where I 
 do put it? How, who, when?)
Resource data in Windows is data compiled into your exe. It is stuff like icons, menus, or other arbitrary stuff you attach. However, the code you posted doesn't access any of that so it shouldn't be an issue here... what import did you use to access the windows api? `import core.sys.windows.windows;` or something else? Also, are you building 32 bit (the default) or 64 bit?
Sep 05 2015
parent reply "Prudence" <Pursuit Happyness.All> writes:
On Sunday, 6 September 2015 at 00:29:13 UTC, Adam D. Ruppe wrote:
 On Saturday, 5 September 2015 at 19:06:15 UTC, Prudence wrote:
 That's about as far as I can get. (what resource data? Where I 
 do put it? How, who, when?)
Resource data in Windows is data compiled into your exe. It is stuff like icons, menus, or other arbitrary stuff you attach. However, the code you posted doesn't access any of that so it shouldn't be an issue here... what import did you use to access the windows api? `import core.sys.windows.windows;` or something else? Also, are you building 32 bit (the default) or 64 bit?
32-bit and I'm using the latest win32 wrappers distributed on github from someone. (suppose to be more complete than core.sys.windows) Obviously the issue is that I'm not using any resources yet it is giving me such an error. (again, I pretty much copied the code directly from MSDN)
Sep 05 2015
parent reply "Kagamin" <spam here.lot> writes:
On Sunday, 6 September 2015 at 02:37:21 UTC, Prudence wrote:
 Obviously the issue is that I'm not using any resources yet it 
 is giving me such an error.
You do. See docs for lpszMenuName field. GUI projects generated by Visual Studio include resource generation, that's why it works for them.
Sep 06 2015
next sibling parent "Adam D. Ruppe" <destructionator gmail.com> writes:
On Sunday, 6 September 2015 at 10:28:59 UTC, Kagamin wrote:
 You do. See docs for lpszMenuName field.
I can't believe I missed that!
Sep 06 2015
prev sibling parent reply "Prudence" <Pursuit Happyness.All> writes:
On Sunday, 6 September 2015 at 10:28:59 UTC, Kagamin wrote:
 On Sunday, 6 September 2015 at 02:37:21 UTC, Prudence wrote:
 Obviously the issue is that I'm not using any resources yet it 
 is giving me such an error.
You do. See docs for lpszMenuName field. GUI projects generated by Visual Studio include resource generation, that's why it works for them.
Thanks! So how does one actually include resources such as menu's (rc files and all that) in a D project? Or am I stuff creating all that stuff programmatically?
Sep 06 2015
parent "Kagamin" <spam here.lot> writes:
On Sunday, 6 September 2015 at 15:42:52 UTC, Prudence wrote:
 So how does one actually include resources such as menu's (rc 
 files and all that) in a D project? Or am I stuff creating all 
 that stuff programmatically?
Just like in a C project: write, compile and link them.
Sep 06 2015
prev sibling parent Rikki Cattermole <alphaglosined gmail.com> writes:
This may interest you:
https://github.com/Devisualization/window/blob/master/platforms/win32/devisualization/window/window.d
Sep 05 2015