Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » Showing Images in a Child Frame
Showing Images in a Child Frame [message #17710] Wed, 27 August 2008 11:46 Go to next message
SirKline is currently offline  SirKline
Messages: 3
Registered: August 2008
Location: Germany
Junior Member
Hi There,

I'm not sure how trivial my question is, but i just can't find out how to display images in a child frame. I started windows programming with upp so my windows programming skills are not so well.

Anyway my paint() is only working with the top frame and i can't figure out how to paint in a child frame.

Thanks in Advance,

SirKline
Re: Showing Images in a Child Frame [message #17717 is a reply to message #17710] Wed, 27 August 2008 13:23 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
Hi and welcome!

I'm afraid you haven't really given enough information for a definitive answer, and there are probably several ways of doing it depending on exactly how you want it to look.

Paint() is clipped to the client area of a ctrl. Frames are objects and responsible for drawing themselves. The simplest way :
// Member variable for the frame (change to Top/Left etc.)
FrameRight<ImageCtrl> imageframe;
...
// In constructor
Image img = AppImg::some_image();
imageframe.SetImage(img); 
AddFrame(imageframe.Width(img.GetWidth()));

But if that's not what you're after, post some more info and we'll help you out.

[Updated on: Wed, 27 August 2008 13:27]

Report message to a moderator

Re: Showing Images in a Child Frame [message #17720 is a reply to message #17717] Wed, 27 August 2008 15:38 Go to previous messageGo to next message
SirKline is currently offline  SirKline
Messages: 3
Registered: August 2008
Location: Germany
Junior Member
Sorry, i was too unspecific / wrong in my question.

Actually my problem is not a child frame but a child window.

I'm working on a card game and i want the possibility to show the last played set of cards in a child window.

I have no problem invoking the window, but i can't show the cards in it.

I hope this is a better explanation.

Please excuse my english since it's no native language.
Re: Showing Images in a Child Frame [message #17724 is a reply to message #17720] Wed, 27 August 2008 16:01 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
What do you mean by child window? Do you mean a widget/control/UI element that is placed inside your TopWindow?

If the answer is yes, you need to create a custom control and override it's Paint method, then place that control normally inside you window and it will paint itself. Each widget, including TopWindow only handles it's own painting via the Paint method. Creating the custom control is simple, just choose you parent class for it, something like StaticRect. If you do not want to paint anything, just want to display an Image loaded from the disk, you do not need to create a custom control, just use one that is capable of displaying an image and insert that in you window.
Re: Showing Images in a Child Frame [message #17736 is a reply to message #17724] Wed, 27 August 2008 18:19 Go to previous messageGo to next message
SirKline is currently offline  SirKline
Messages: 3
Registered: August 2008
Location: Germany
Junior Member
I have a main window, where you play the game. If requested i want to show the last set ( 4 cards) via a menu-entry in a child window.

Right now I'm using an empty *.lay layout with an ok button and wanted to draw the 4 cards (stored in cards.iml) on the layout?

Is this a wrong way?
Re: Showing Images in a Child Frame [message #17738 is a reply to message #17736] Wed, 27 August 2008 19:11 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
I would suggest creating a custom widget based on Ctrl, and overloading it's Paint method to draw the cards.

Something like:
class CardView : public Ctrl
  virtual void Paint(Draw &w) {
    w.DrawRect(GetSize(), SColorFace);
    // Draw cards
  }
};


As long as you declare this before you include your .lay file (or include a header with it in) you can add CardView to your child window's layout using 'User class' from the Layout Manager context menu.

[Updated on: Wed, 27 August 2008 19:12]

Report message to a moderator

Re: Showing Images in a Child Frame [message #18021 is a reply to message #17738] Sun, 07 September 2008 08:42 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mrjt wrote on Wed, 27 August 2008 13:11

I would suggest creating a custom widget based on Ctrl, and overloading it's Paint method to draw the cards.

Something like:
class CardView : public Ctrl
  virtual void Paint(Draw &w) {
    w.DrawRect(GetSize(), SColorFace);
    // Draw cards
  }
};


As long as you declare this before you include your .lay file (or include a header with it in) you can add CardView to your child window's layout using 'User class' from the Layout Manager context menu.


BTW, you can even declare this after including .lay and leave the type of widget empty, then declare it inside dialog struct...

Mirek
Previous Topic: Premultiply - Wrong expression
Next Topic: EXIF data access
Goto Forum:
  


Current Time: Thu Mar 28 11:37:09 CET 2024

Total time taken to generate the page: 0.01207 seconds