Combining two arrays

Hello.
I'm trying to get the path to the .exe, and add "bg.jpg" to the array to display the image that's in the same Path as the .exe...didn't work so far >.>
Any hints?:) thanks ahead.

1
2
3
4
5
6
7
8
9
BOOL ImageBox_SetImage(HWND hwndImageBox, LPCTSTR szImagePath)
{
	LVBKIMAGE lv = { 0 };

	lv.ulFlags =  LVBKIF_STYLE_NORMAL | LVBKIF_SOURCE_URL;
	lv.pszImage = (LPTSTR) szImagePath;

	return ListView_SetBkImage(hwndImageBox, &lv); 
}


1
2
3
4
5
6
7
8
9
10
		case WM_CREATE:
		{
			TCHAR PathBuffer [MAX_PATH];
			char Image[] = "\\bg.jpg";
			GetModuleFileName(NULL, PathBuffer, MAX_PATH);

			HWND hwndImage = CreateWindowEx(0, WC_IMAGEBOX, TEXT(""), WS_CHILD | WS_VISIBLE, 0, 0, 500, 263, hwnd, NULL, (HMODULE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE), NULL);
			ImageBox_SetImage(hwndImage, PathBuffer + TEXT("\\bg.jpg"));
			return 0;
		}
Last edited on
What's this ?
ImageBox_SetImage(hwndImage, PathBuffer + TEXT("\\bg.jpg"));


You need this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// header and library, for gcc is different
#include <shlwapi.h>
#pragma comment(lib, "shlwapi.lib");

        TCHAR PathBuffer [MAX_PATH];
	GetModuleFileName(NULL, PathBuffer, MAX_PATH);
	PathRemoveFileSpec(PathBuffer);
	_tcscat(PathBuffer, TEXT("\\bg.jpg"));

// and then ...
     
ImageBox_SetImage(hwndImage, PathBuffer);

Thank you VERY much :)

for others who might find this post:
You might need to use the

1
2
strsafe.lib
and <strsafe.h>
Topic archived. No new replies allowed.