cxDbImage loads a picture from database. Kind of thumbnail.
How can I have this pictures shown a little bigger out of the cxdbimage
container when I click on the picture inside ?
I have some projects that use this kind of functionality. I simply have created a form with a TcxImage inside (align alClient).
Then, on cxDbImage DbClick event, I just perform something like this:
FMyForm := TMyForm.Create(Self);
try
FMyForm.cxImage1.Picture := cxDBImage1.Picture;
FMyForm.ShowModal;
finally
FreeAndNil(FMyForm);
end;
If I understood your question correctly, this approach can help you.
Related
I'm making a game of connect 4 in delpi. I need to put the correct coloured circle in the correct place, according to where the user has clicked. How do you load an image (JPEG prefereably) into a specific cell?
I have no idea where to start with this (because my teachers are useless lol) so any help would be so appreciated.!!
on form create:
images:=timagelist.Create(self);
image1:=tjpegimage.Create;
image2:=tjpegimage.Create;
bimage1:=tbitmap.Create;
bimage2:=tbitmap.Create;
try
image1.loadfromfile('red.jpg') ;
bimage1.Assign(image1);
image2.loadfromfile('yellow.jpg') ;
bimage2.Assign(image2);
finally
image1.free;
image2.free;
end;
images.Add(bimage1,nil);
images.Add(bimage2,nil) ;
on drawcell:
row:=c4grid.Row;
col:=c4grid.Col;
images.Draw(c4grid.Canvas,row,col,0);
So far nothing happens, and there is no evidence that you can actually click the cell. Any help/advice/guidance would be much appreciated!
I have three buttons placed at the right on my form. The buttons' anchor property parameters akTop, akRight are set to true, the other ones left to false so that the buttons always remain at the right side near the boarder when the form is resized. Then I set the form's WindowState property to wsMaximized so that it covers the whole screen when run at start-up. But when I start the application the buttons are closer to the middle rather than on the right. But when I resize the form at design-time everything seems to work just fine.
Here are some snapshots to show you exactly what I mean:
At design-time:
At run-time:
Please, explain what I'm doing wrong and how to fix this so that it works as intended.
This looks like the buttons are being created with their designed positions, the form is then set to Maximized, then the anchor properties are set or put in place.
In design time the anchors are already set and so that’s why you see them move as you want. To prove my theory on this make the form much smaller, run the application and notice that the items are in their smaller design time locations.
An easy fix to get what you want. Keep the Window state at wsNormal and on FormShow (which occurs after Create) do this:
procedure TForm1.FormShow(Sender: TObject);
begin
self.WindowState := wsMaximized;
end;
You will see the results you want.
I have seen your answer in one of those tutorials. But realy dont remember was which one. You can watch all videos, even you will learn more things. it will not time waste all the way.
Link: Learn Delphi TV
Also you can try something like below if you are lazy enough to watch videos. Put this code in form resize:
buttoncreate.left := panel.width - (buttoncreate.width + buttonedit.width + buttondelete.width);
buttonedit.left := panel.width - (buttonedit.width + buttondelete.width);
buttondelete.left := panel.width - buttondelete.width;
After searching around the web for about half an hour i've decided to ask for some help.
Currently i'm using this code:
procedure TViewSalesActivity.btnPrintClick(Sender: TObject);
begin
with TPrintDialog.Create(nil) do
ViewSalesActivity.PrintScale:= 1.5
try
if Execute then
ViewSalesActivity.Print;
finally
Free;
end;
end;
To print a whole form.
The form includes buttons, text, captions and edit boxes etc.
The only problem is that the printout is to scale of the computer window; which is way too small. It is also stuck in the top left hand corner of the page. Is there any way to make it fill a whole page/ majority of the page?
Assuming which the ViewSalesActivity variable is a TForm descendant, try setting the PrintScale property to poPrintToFit
ViewSalesActivity.PrintScale:=poPrintToFit;
ViewSalesActivity.Print;
I have an application that uses a frame extensively and needs to hide/show certain buttons depending on which form is active at the time. In order to keep the buttons neat and organized appropriately, I have put them on panels and show or hide the panels as needed for each form. My problem is when each form is initially created, the panels on the frame are out of order even though I am explicitly telling them which order to put themselves into. After I hide and re-show the form, the panels are in the correct order. Any suggestions on how to keep them in the proper order from the very beginning?
Instead of giving the panels explicit positions, try giving them alignments. They tend to stick better than way, and they do a better job of resizing if you resize the form.
You can also try using a stackpanel (or was it flowpanel?) as parent for the panels. Then you will have a order instead of a position to manipulate.
Maybe you can have a look at the DevExpress LAyoutControl? It helps us creating interfaces that always look good, no matter if we show or hide certain groups / panels. It even allows for run-time customization of the interface, if you want that!
You may try to organize them by coordinates i.e.: setting Top and Left. Unless your panels are aligned, this will always work (but it takes bit lot of work).
I had this problem and I found that the solution was to do this in FormCreate (or in a CMShowingChanged method of your frame):
MyPanel1.Align := alNone;
MyPanel2.Align := alNone;
MyPanel1.Align := alBottom;
MyPanel2.Align := alBottom;
Restore in the order that you need - this seemed to sort out the order visually.
I have a problem I am unable to solve even though I spend long time trying to do it.
I usually use GridPanels to align controls on forms. It has, however, an annoying bug. When the GridPanel align mode is alClient and I maximize its parent window, the GridPanel adjusts to the new size of that window, however, the controls laying on the grid do not. They stay in the same position they were before window resize.
It happens only at the first window's maximization. If the window is first resized manually, everyting is OK. I think the grid adjusts its child controls after the second resize event (??).
What to to do make GridPanel work properly if it comes to this bug? It might be enough to send a message to it (but what message?), I do not know. I tried to use Realign, Refresh etc., but they did not help.
Thanks for your help in advance,
Mariusz.
Ah, I've had similar issues as well. It might be related to a resizing problem in the VCL. You might want to try the fix by Andreas Hausladen. It seems to work for me in most of the cases.
Changing the width / invalidating the control doesn't work for me (something changed with recent versions of RAD Studio?).
Anyway a similar, simple workaround along that line is:
procedure TForm1.FormResize(Sender: TObject);
begin
GridPanel1.ControlCollection.BeginUpdate;
GridPanel1.ControlCollection.EndUpdate;
end;
I found one trick.
in OnResize event of parent of gridpanel, change gridpanel's width by 1 pixel.
then gridPanel will notice size changed, then rearrange sub-controls in gridpanel..
sample is below..
procedure TForm1.FormResize(Sender: TObject);
begin
GridPanel1.Width := GridPanel1.Width - 1; // subtract 1
GridPanel1.Width := GridPanel1.Width + 1; // recover width by adding 1
end;
I have had this error too, on several projects. I'm not sure how I solved this (it was on projects for my previous employer, I don't have access to this source code anymore). I think I had te redraw / refresh that parent frame or form on which the GridPanel was placed.
on the resize of the owner call GridPanel.Invalidate.
I didn't test it. I hope it's work.