PocketMatrix forums

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

Loading Images

PointOfLight · 23 Apr 2004, 20:35 UTC
How do you load a bitmap when using the standard CE GUI interface? Does PPL have a way to do that, or do you have to use a 3rd party library?
I will certainly try to figure out a way to implement custom GUI components into PPL in a near future. What you can do right now is use the standard hDC paint technic. Look at the main.ppl source code in the WM_PAINT event, you will find out how it is done. :idea:

I will look into this issue next week and figure out what is the best way to do this at this point until the custom component creation is implemented. Maybe the whole custom component thing will appear in 0.3... :wink:

Regard,
Kornalius
PointOfLight · 23 Apr 2004, 22:46 UTC
Using the WM_PAINT event isn't the problem. What I was actually wondering was how to load the bitmap itself. I noticed the LoadImage command, but that assumes that the image has been compiled into the executable. I need a way to load an image from disk (or is it possible to use resource files with PPL?)
Try this:

Code:
filename$ = "\\My Documents\\Image.bmp";
img$ = LoadImage(NULL, filename$, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
delete(img$); // Once done with it


This should work. I am not sure I have declared and defined everything in here (from Lib directory) but I think everything is there.

Let me know,
Regards,
Kornalius
PointOfLight · 24 Apr 2004, 05:40 UTC
I'm getting an error "Invalid number of parameters at LOADIMAGE (67,9). I copied the code just as you wrote it (even used the variable filename$. Help! I've put the code I've written so far out at http://www.csdatasol.net/Downloads/First_prog.PPL

If someone could take a look it would be greatly appreciated.
Hi,

Maybe the LoadImage declaration in Lib\Windows.ppl is wrong. I will fix it for the next version.

Btw, you don't have to convert to WideChar when using API functions.

Code:
strCombo$ = Wide("Item #" + intCnt$);
SendMessage(c$, CB_ADDSTRING, 0, &strCombo;$);


This code could be changed to this:

Code:
SendMessage(c$, CB_ADDSTRING, 0, "Item #" + intCnt$);


This should work also, PPL does the conversion on strings automatically. It doesn't do conversion on output results though.

Regards,
Kornalius
PointOfLight · 24 Apr 2004, 19:36 UTC
If I make changes to windows.ppl, will PPL recognize them, or do they get complied into the PPL executable? I tried adding the BitBlt command, which I noticed you left out, but PPL wouldn't recognize it. Maybe you could add that to the next verison as well. As far as the LoadImage command goes, it looks fine according to MSDN. The program actually runs the first time without error, then errors the second time you try and run it.
Hi,

If you had a declaration to Lib\Windows.ppl, everytime you run PPL it will load the declaration. But if your program is already compiled, PPL won't compile it again, you need to explicitely tell PPL to compile the project, select the File/Compile menu option.

Can you send me your code at the beta support email address. I will check it tomorrow or Monday.

Yes, I left a LOT of API functions out because it's very time consuming to add and I couldn't test them all. As the beta progress there is going to be more and more added. :D

Regards,
Kornalius
PointOfLight · 25 Apr 2004, 04:27 UTC
I completely understand that you had to pick and choose the APIs that you included for this first run. I'm just so used to BitBlt as kind of a "standard" API that it was wierd to see it missing. But I made due :) I will definitely forward that code off to you at some point. Thanks.
Hi,

Sorry about confusing you with the LoadImage, unfortunately the LR_LOADFROMFILE is not supported in WinCE. You must use the SHLoadDIBitmap function. Use the following declaration in your program:

Code:
#declareapi SHLoadDIBitmap "aygshell.dll" SHLoadDIBitmap 1 1
#declare BitBlt apidll BitBlt 9 1


This should work.

Code:
b$ = SHloadDIBitmap("\\My Documents\\MyFile.bmp");
hdc$ = GetDC(hWnd$);
hdcMem$ = CreateCompatibleDC(hdc$);
hOldSel$ = SelectObject(hdcMem$,b$);
BitBlt(hdc$,rect.left$,rect.top$,rect.right$,rect.bottom$,hdcMem$,0,0,SRCCOPY);


The BitBlt will be included in the next release too.

Regards,
Kornalius
I will still try to figure out why your LoadImage in the code was generating an error.

Regards,
Kornalius
PointOfLight · 26 Apr 2004, 01:34 UTC
kornalius wrote:I will still try to figure out why your LoadImage in the code was generating an error.


I don't think it was the LoadImage per se. I think it was because once the LoadImage failed I wasn't trapping against the img$ variable, so I was trying to use the unassigned variable in the draw routine. I was also doing a DeleteObject against the unassigned object. I think this is what was causing my problem.
PointOfLight · 26 Apr 2004, 01:36 UTC
I tried the SHLoadDIBitmap function, and I get a syntax error on that line when I try to run my program. Just out of curiosity, will you be able to use standard controls in combination with the graphic rendering of PocketHAL? If so that might solve some of my problems.
The SHLoadDIBitmap is not defined in version 0.1a, it will be in 0.2. That is probably why you are getting an error.

As for PocketHAL, I will look into it and see what I can do. I have a long list of things to do for 0.2 and some more for future versions, I will add it to the list! :wink:

Regards,
Kornalius
PointOfLight · 26 Apr 2004, 12:38 UTC
What do you mean by "defined"? I thought all you had to do was add a #declare or #declareapi statement and you could use a function from any DLL. Is that not actually the case?
Yes it it, sorry I used the word "defined" when I should have used "declared".

Regards,
Kornalius
Ok, found the problem with SHLoadDIBitmap, replace "aygshell.dll" with apidll in the declaration. The function is located inside coredll.dll.

#declareapi SHLoadDIBitmap apidll SHLoadDIBitmap 1 1

Regards,
Kornalius

Btw, I am testing the custom component system that I am implementing. I am doing a test with an IMAGE component. So you will get a chance to see how you can load and draw bitmaps in PPL in the next build. :D
PointOfLight · 26 Apr 2004, 15:52 UTC
So how soon until this next build :D
A couple days at max I hope! 8)
PointOfLight · 26 Apr 2004, 16:36 UTC
Success! I finally got a bitmap to load! Thanks for all your help.