PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Where does it put the bitmap?

I am trying to load a bitmap but I am confused where it is suppose to be.. in normal PC programming you put it in the directory of where the compiled program is. But that does not seem to happen with the pocketPC.. or must I manually copy the BMP files to the /start menu folder on the PPC?

anyways here is the line it is failing at

Code:

//open the file
hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
return FALSE;
}


I have put 'space8.bmp' (which is the szFileName) everywhere yet it still gives me that error. any ideas?

where are the docs for Createfile found anyways..
What I do in cases like this:

Just write a file instead of reading and look where
it is. :)

Regards.. Marco.
Well, this may help you. Windows CE does not have a working directory. Instead, '\' is always considered the current directory. So, if you try to just load psx.bmp, it will try and load '\psx.bmp' As for including with the project, you must manually add it to your project, in which case the bitmap will get a special handle (user definable) which you can use to load it throughout the program.
The easiest way to handle this is to make all your paths relative to the location of the main program EXE. That way you aren't hardcoding your paths (which is bad for many reasons - Storage Card installs, non-english devices, etc). You can use GetModuleFileName to get the path and filename of the current running exe. Extract the path, and slap it on the beginning of all the files you need to load.

Dan East
UMCP_matt · 28 Jun 2002, 17:39 UTC — resrouces
I hear you can also just package the bitmaps in a resrouce file with the executable so it is all just one file

is this the preferred method?
Dan East wrote:
The easiest way to handle this is to make all your paths relative to the location of the main program EXE. That way you aren't hardcoding your paths (which is bad for many reasons - Storage Card installs, non-english devices, etc). You can use GetModuleFileName to get the path and filename of the current running exe. Extract the path, and slap it on the beginning of all the files you need to load.

Dan East
Gee, That would be handy for people that have trouble installing PocketQuake
UMCP_matt,

Here's something that will retrieve the full path of the executable.

Code:

DWORD GetModuleDirectory (HMODULE hModule, LPTSTR szPath, DWORD dwLength)
{
DWORD dwLen;
LPTSTR p;

if (0 == (dwLen = GetModuleFileName(hModule, szPath, dwLength)))
return(0);

p = szPath + dwLen;
while (p != szPath)
{
if (TEXT('\\') == *--p)
{
*(++p) = 0;
break;
}
}

return(p - szPath);
}

int WINAPI WinMain (HINSTANCE, HINSTANCE, LPTSTR, int)
{
TCHAR szPath[MAX_PATH];

GetModuleDirectory(GetModuleHandle(NULL), szPath, sizeof(szPath) / sizeof(szPath[0]));

return 0;
}




I wouldn't recommend that you store large bitmaps as resources in your exe or dll. The reason is that you'll be taking up twice as much memory for a single bitmap (one copy in the r/o data segment of your exe, and one copy in the GDI object).
UMCP_matt · 28 Jun 2002, 19:35 UTC — ok
I ran your function and it returns

+ p 0x2602f934 ""
+ szPath 0x2602f90c "\Windows\Start Menu\"

the exe is inside the startmenu on the PPC so I assume that means I should put the BMP there also.. so that is what I do. I have the file 'space8.bmp' in the same directory..

so it encounters the line
Code:

if (!cbSpace->Load(_T("space8.bmp")))



which eventually calls

Code:

hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
return FALSE;
}


bRet 0
hFile 0xffffffff
+ szFileName 0x0001519c "space8.bmp"
+ this 0x000322d8


ARG!!!!!

but its there!!
UMCP_matt · 28 Jun 2002, 20:03 UTC — trying to just write a file
Code:

LPCSTR fn = _T("test.bmp");
hFile = CreateFile(fn, GENERIC_WRITE, FILE_SHARE_WRITE, NULL,
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
CloseHandle(hFile);


but it does not even return a handle to me! 8O
Moose, PWolf and DEXplor use relative paths.

UMCP_Matt, you need to load relative to the application's path. To expand on Digby's source:

Code:

TCHAR szPath[MAX_PATH];

GetModuleDirectory(GetModuleHandle(NULL), szPath, sizeof(szPath) / sizeof(szPath[0]));

_tcscat(szPath, _T("test.bmp"));
HANDLE hFile = CreateFile(szPath, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);

CloseHandle(hFile);


Dan East
UMCP_matt · 28 Jun 2002, 21:53 UTC — ok.. i got it
another simeple question

how come it keeps asking me where gx.dll is?

but even if I cancel it runs fine..

I included gx.lib in the settings so it shouldnt care about gx.dll right?
That's just the debugger asking for a local, debug version of the DLL. If you provide a debug version (MS didn't provide a debug version of gx.dll, so you can't for that DLL) then you could step into the DLL and debug just like with your app. MS does provide debug versions of some DLLs such as MFC, etc.

Dan East
umcpmatt · 29 Jun 2002, 03:29 UTC — im new so some of these questions seem simple
so I cdan never get rid of that notice about gx.dll

how come MS does not provide a debug version anyways?

since I have a XSCALE the only way to take advantage of it is write assembly.. or could someone write a library and then I could use that?
There should be two different ways to remedy that. First you can extract gx.dll to your PC somewhere, and when it asks for the dll browse and select it (make sure you use the gx.dll to match your processor type). It still may warn you that gx.dll does not contain debugging info, but I don't think it will say that every time you start a debug session.

Second, if you go into the Project Settings, "Debug" tab, and select "Additional DLLs" you will see an option "Try to locate other DLLs". Try unchecking that option.

There's really no need for a debug version of gx.dll. That library does very little, and more importantly, does not do extensive calling into other libraries. Some libraries, like MFC.dll, are pretty complex and make calls into user code, so it is very important that debug versions are provided so the entire call stack can be navigated.

Dan East
UMCPmatt · 29 Jun 2002, 06:44 UTC — more random thoughts
wouldnt the gx.dll be different for each processor since they all have unique hardware.. especially this ATI imageon? Does ANY code out there exist that takes advantage of this new gfx processor anyways?

And how dare them get rid of the close button in PPC apps? I do not really understand this since it is a pain to goto another menu to close a app.

where in virginia are you? I'm in sterling
UMCPmatt · 30 Jun 2002, 04:43 UTC — other thoughts
anyone have the problem of the activesync sorta randomly disconnecting? I have. I need to take it out of the cradle and put it back in.. its a pain

especially when I am in the middle of debugging
slightly ot: What program is that?

the one you all are coding in
BurningSheep · 30 Jun 2002, 12:05 UTC
no, activesync is the program most of us use to synchronize our PPC with out PC. You don't have it installed?

eVC (where most people program in) uses the activesync connection to your PPC to put the files on your device.

neways, I don't have it randomly disconnecting, but sometimes for no obvious reason it doesn't allow me to connect anymore. Even after killing activesync and restarting it, the only solution then is to reboot the entire system (win2k). Pretty annoying, maybe my com port just sucks :|
UMCPmatt · 01 Jul 2002, 05:16 UTC — me too
sometimes it just will not connect so I need to unplug and replug the USB

can gapi programs run on the emulator or not?
>can gapi programs run on the emulator or not?

Not directly but you can get a GAPI emulator from frog.flipcode.com which emulates GAPI with slower GDI bitmaps.