Discussions related to Visual Prolog
User avatar
abdelrahman
Posts: 16
Joined: 13 Sep 2009 6:23

How can I Put a BMP Image as a background for the Taskwindow when program starts

Post by abdelrahman »

I want program to appear like this when starts
You do not have the required permissions to view the files attached to this post.
User avatar
drspro2
VIP Member
Posts: 131
Joined: 28 Apr 2006 12:03

Re: How can I Put a BMP Image as a background for the Taskwindow when program starts

Post by drspro2 »

in the old Vip52 you could draw images directly to the taskwindow, which ment that the taskwindow was 'drawable'. in the new visual-prolog i do not know if that is the case.

what certainly would be possible is to make a new ( window or form or dialog) which will always remain on top of the taskwindow which will contain the image. there exists also an Image-control ( when you right click add a control in the designer ) to put inside that window which is the most easy because it can handle the resizing.

This new window would always have to stay fully maximized to make it cover your whole application OR you have to dynamically resize the new window by asking the Size of the parent and then resize this window accordingly.

Also in the Examples projects there always used to be a sort of Splash example which does about the same thing, and then it shouldnt disappear/close after the splash, though i do not see that example anymore.

and apparantly you dont use the Messages window in your application which would make things more complicated, so you do not have this problem.

But certainly it has to be possible to show a full size BMP in the app.

In other applications i used the web-browser example where i simply put the image/bmp full screen in the web-browser control.

in the examples directory there is also the pictureDraw example
User avatar
Thomas Linder Puls
VIP Member
Posts: 1510
Joined: 28 Feb 2000 0:01

Re: How can I Put a BMP Image as a background for the Taskwindow when program starts

Post by Thomas Linder Puls »

It can be done using some low-level handling:

Code: Select all

predicates     onShow : window::showListener. clauses     onShow(_, _CreationData) :-         initBackground(),         _MessageForm = messageForm::display(This).   predicates     initBackground : (). clauses     initBackground() :-         MdiClient = getMdiClientWindow(),         old :=             uncheckedConvert(gui_native::wndProc,                 gui_native::setWindowLongPtr(MdiClient:vpiWindow, gui_native::gwl_wndproc, uncheckedConvert(handle, myWndProc))),         addSizeListener({  :- MdiClient:invalidate() }). % necessary if the image change position or is resized   class facts     old : gui_native::wndProc := erroneous.     backgroundImage : image := image::createFromFile(@"..\bg.jpg").   constants     edge : integer = 10.   class predicates     myWndProc : gui_native::wndProc. clauses     myWndProc(Window, gui_native::wm_erasebkgnd, WParam, _LParam) = gui_api::rTrue :-         !,         DC = uncheckedConvert(gui_native::hDC, WParam),         Rct = gui_api::getClientRect(Window),         HBrush = gui_native::createSolidBrush(vpiDomains::color_bisque),         gui_api::fillRect(DC, Rct, HBrush),         gui_api::deleteObject(HBrush),         Graphics = graphics::createFromHDC(DC),         rct(_, _, W, _H) = Rct,         X = math::max(edge, (W - backgroundImage:width) div 2),         Graphics:drawImageI(backgroundImage, X, edge).       myWndProc(Window, Message, WParam, LParam) = gui_native::callWindowProc(old, Window, Message, WParam, LParam).
Here I have chosen to center the image on the x-axis, because that requires repainting the image each time the application rescales. I have also added a background color, because my image is "small".

Handling the image size and positioning is the hardest problem/decisions. Should it move, should it be resized (be careful with proportions), ...
You do not have the required permissions to view the files attached to this post.
Regards Thomas Linder Puls
PDC
User avatar
abdelrahman
Posts: 16
Joined: 13 Sep 2009 6:23

Re: How can I Put a BMP Image as a background for the Taskwindow when program starts

Post by abdelrahman »

Thank you Very much for your Code and your attached file
It worked well.
so Grateful for your Help .
User avatar
Thomas Linder Puls
VIP Member
Posts: 1510
Joined: 28 Feb 2000 0:01

Re: How can I Put a BMP Image as a background for the Taskwindow when program starts

Post by Thomas Linder Puls »

👍
Regards Thomas Linder Puls
PDC