Register
Site Login
Site Search
Forums
Advertisement
Welcome to PocketMatrix. PocketMatrix is dedicated to providing the best online community for mobile device developers and enthusiests. What's new?

Loading Images


Loading Images

Postby PointOfLight » Apr 23, 2004 @ 9:35pm

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?
Eric Pankoke
Programmer
Point Of Light Software
http://www.polsoftware.com/
PointOfLight
pm Member
 
Posts: 525
Joined: Nov 2, 2003 @ 8:39pm


Postby kornalius » Apr 23, 2004 @ 10:29pm

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
User avatar
kornalius
pm Member
 
Posts: 1704
Joined: Dec 9, 2003 @ 6:04pm
Location: Montreal, Québec, Canada


Postby PointOfLight » Apr 23, 2004 @ 11:46pm

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?)
Eric Pankoke
Programmer
Point Of Light Software
http://www.polsoftware.com/
PointOfLight
pm Member
 
Posts: 525
Joined: Nov 2, 2003 @ 8:39pm


Postby kornalius » Apr 24, 2004 @ 2:55am

Try this:

Code: Select all



filename$ = "\\My Documents\\Image.bmp";
img$ = LoadImage(NULL, filename$, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
delete(img$);  // Once done with it
3 lines; 1 keywds; 2 nums; 14 ops; 1 strs; 1 coms    Syntactic Coloring v0.4 - Dan East  


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
User avatar
kornalius
pm Member
 
Posts: 1704
Joined: Dec 9, 2003 @ 6:04pm
Location: Montreal, Québec, Canada


Postby PointOfLight » Apr 24, 2004 @ 6:40am

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.
Eric Pankoke
Programmer
Point Of Light Software
http://www.polsoftware.com/
PointOfLight
pm Member
 
Posts: 525
Joined: Nov 2, 2003 @ 8:39pm


Postby kornalius » Apr 24, 2004 @ 7:02pm

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: Select all


strCombo$ = Wide("Item #" + intCnt$);
SendMessage(c$, CB_ADDSTRING, 0, &strCombo$);
2 lines; 0 keywds; 1 nums; 12 ops; 1 strs; 0 coms    Syntactic Coloring v0.4 - Dan East  


This code could be changed to this:

Code: Select all

SendMessage(c$, CB_ADDSTRING, 0, "Item #" + intCnt$);
1 lines; 0 keywds; 1 nums; 7 ops; 1 strs; 0 coms    Syntactic Coloring v0.4 - Dan East  


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

Regards,
Kornalius
User avatar
kornalius
pm Member
 
Posts: 1704
Joined: Dec 9, 2003 @ 6:04pm
Location: Montreal, Québec, Canada


Postby PointOfLight » Apr 24, 2004 @ 8:36pm

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.
Eric Pankoke
Programmer
Point Of Light Software
http://www.polsoftware.com/
PointOfLight
pm Member
 
Posts: 525
Joined: Nov 2, 2003 @ 8:39pm


Postby kornalius » Apr 25, 2004 @ 5:00am

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
User avatar
kornalius
pm Member
 
Posts: 1704
Joined: Dec 9, 2003 @ 6:04pm
Location: Montreal, Québec, Canada


Postby PointOfLight » Apr 25, 2004 @ 5:27am

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.
Eric Pankoke
Programmer
Point Of Light Software
http://www.polsoftware.com/
PointOfLight
pm Member
 
Posts: 525
Joined: Nov 2, 2003 @ 8:39pm


Postby kornalius » Apr 25, 2004 @ 6:10pm

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: Select all


#declareapi SHLoadDIBitmap  "aygshell.dll" SHLoadDIBitmap 1 1
#declare BitBlt apidll BitBlt 9 1
2 lines; 0 keywds; 4 nums; 0 ops; 1 strs; 0 coms    Syntactic Coloring v0.4 - Dan East  


This should work.

Code: Select all





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);
5 lines; 0 keywds; 2 nums; 32 ops; 1 strs; 0 coms    Syntactic Coloring v0.4 - Dan East  


The BitBlt will be included in the next release too.

Regards,
Kornalius
User avatar
kornalius
pm Member
 
Posts: 1704
Joined: Dec 9, 2003 @ 6:04pm
Location: Montreal, Québec, Canada


Postby kornalius » Apr 25, 2004 @ 6:11pm

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

Regards,
Kornalius
User avatar
kornalius
pm Member
 
Posts: 1704
Joined: Dec 9, 2003 @ 6:04pm
Location: Montreal, Québec, Canada


Postby PointOfLight » Apr 26, 2004 @ 2:34am

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.
Eric Pankoke
Programmer
Point Of Light Software
http://www.polsoftware.com/
PointOfLight
pm Member
 
Posts: 525
Joined: Nov 2, 2003 @ 8:39pm


Postby PointOfLight » Apr 26, 2004 @ 2:36am

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.
Eric Pankoke
Programmer
Point Of Light Software
http://www.polsoftware.com/
PointOfLight
pm Member
 
Posts: 525
Joined: Nov 2, 2003 @ 8:39pm


Postby kornalius » Apr 26, 2004 @ 12:35pm

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
User avatar
kornalius
pm Member
 
Posts: 1704
Joined: Dec 9, 2003 @ 6:04pm
Location: Montreal, Québec, Canada


Postby PointOfLight » Apr 26, 2004 @ 1:38pm

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?
Eric Pankoke
Programmer
Point Of Light Software
http://www.polsoftware.com/
PointOfLight
pm Member
 
Posts: 525
Joined: Nov 2, 2003 @ 8:39pm


Next

Return to Pocket Programming Language (PPL)


Sort


Forum Description

Discuss this new development tool.

Moderator:

kornalius

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron