April 27, 2024, 01:41:53 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


GDI Help - sorry, I posted the last one in the wrong section!

Started by Brian, March 20, 2024, 10:24:17 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Brian

I'm trying to replace the "mushroom.gif" part of this GDI call with a variable:
   result=GdipLoadImageFromFile(L"mushroom.gif",pImage)

Like so:
   result=GdipLoadImageFromFile(LvariableName,pImage)

but it doesn't like it all. Any ideas?

Out of interest, I am putting together a GDI image viewer, and this is my only stumbling-block at the moment. There will be others, no doubt, but this is the main one

Brian

LarryMc

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Brian

Larry,

I am getting a result now, using WSTRING and S2W, and a bit of calafudging. Then I found out that you can "Dispose" and "Delete" a GDI-drawn image, but it doesn't delete it from the screen, so all the images pile on top of one another. Working on that now, and getting somewhere. Then it will be a look at what happens when you resize the window. . . .

Brian

Brian

March 22, 2024, 10:09:06 AM #3 Last Edit: March 22, 2024, 11:01:13 AM by Brian
Okay, here is my very simple GDI picture viewer. A bit to do on it yet, like resizing a picture that is too big to fit in the client area; maybe more info about a picture's quality, etc; change the statusbar to more meaningful output; add a menu. Things to do as I get the inspiration!

Currently it will load BMP, GIF, JPG, JPEG, PNG, TIF, TIFF and ICO formats, and display them
There is a filter in place so that the File Listbox only displays those formats
I have zipped up some images for you to test

You will have to generate a lib from the Pbsctrl.dll

Brian

Egil

March 23, 2024, 05:35:49 AM #4 Last Edit: March 23, 2024, 05:39:03 AM by Egil Reason: Pic showing twice...dont understand why
Hi Brian!
It's nice to see that you have been rather busy when I have been away.
I'm still unable to use IWB, so glad you also included the exe file.
So far your program looks great, but here my laptop gives an error every ntime I start your program, and when i click "OK" in the error box your program starts, and appears to work as intended.
I'll check your code later, but there must be something in the file loading routine that my pc don't like.
Anhow, I really like what you have done so far!  :)


Egil
Support Amateur Radio  -  Have a ham  for dinner!

Brian

March 24, 2024, 05:38:22 AM #5 Last Edit: March 24, 2024, 08:55:54 AM by Brian Reason: Wrong answer
Egil,

Good to hear from you - hope you are doing well

It's not an error, really. It's just saying that the last-used path in the ini file is not the same that you are launching the program from. It should save your last-used directory when you close it. Have a looksee...

I could be posting another version today, and this will be a Project type, but I will include the exe again

Brian

Edit: Correction, after looking at my code and the message, it just means that that path is not available. So it was okay on my PC, but not yours!

Egil

Came home late friday night, but going back after Easter.
Had just started looking at your code in Notepad when I decided to check the Forum.
Just deleted the included ini file, and the error was gone!
Never used GDI myself, so will study your code to see how it is done.

All the best!
Egil
Support Amateur Radio  -  Have a ham  for dinner!

Brian

Update:

Added EMF and WMF filetypes as allowed formats
Added a menu for later additions
Changed the main program icon
Coloured the statusbar, and added an icon
Added image horizontal and vertical resolutions to the statusbar
Added VERSIONINFO into the resource (.rc) file

Removed previous upload, as the program is now a Project

Brian

Brian

Sorted the proportionate sizing of images, so if an image will fit in the window, no resizing is done; if the image is too big to fit in the window, then it is proportionately resized. Code and exe in the zip

Brian

Brian

I think I have taken this program as far as I want, so I doubt I will be doing any more on it. Don't fancy having to learn more of the hundreds of GDI calls, really!

Added bitmaps to the menus
Added an About box
Added more file info into the Statusbar
Slight update to the image proportion code
Exe included

Brian

Brian

OK, couldn't resist! Now when the window is resized, the loaded image is redrawn to fit the window. Before, you had to first click a filename, resize your window, and then click the filename again

Bit of slight flickering going on, but I can live with that. Very easy fix, as well

Exe and source code in the zip

Brian

Brian

Sorry about this, but while I was giving the program a good run through yesterday, I found it was hanging up at times when changing to different directories

I think I have fixed the problem, so please use this version instead

Brian