ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Canvas does not allow drawing - DoPrintPreviewDlg
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

BMurdoch

USA
8 Posts

Posted - Dec 30 2015 :  09:23:22  Show Profile  Reply
I have just upgraded to v6.2.1 in Delphi from a much older version. I have been using the following to display a print preview for the user:

FImageENView.IO.DoPrintPreviewDialog(iedtDialog, lPageNbr.Caption, true, lPageNbr.Caption);


In this new version, I am receiving an error "Canvas does not allow drawing" when calling this method. Closing the error dialog does allow the preview dialog to show and perform as usual.

The call stack looks like this:

main thread ($1888):
40035142 +042 Vcl50.bpl Graphics TCanvas.RequiredState
4003503e +012 Vcl50.bpl Graphics TCanvas.GetHandle
008819e3 +017 idls.exe hyieutils IEInitializeComboBox
0081f6c5 +009 idls.exe ieprnform1 TfiePrnForm1.FormCreate
4005331d +031 Vcl50.bpl Forms TCustomForm.DoCreate
4006b7c1 +111 Vcl50.bpl Controls TControl.WndProc
4006e376 +1d2 Vcl50.bpl Controls TWinControl.WndProc
008f2749 +1e1 idls.exe imageenio TImageEnIO.DoPrintPreviewDialog
00a73b2c +058 idls.exe PODImageForm 256 +1 TfrmPodImage.PrintImage

Please advise.

w2m

USA
1990 Posts

Posted - Dec 30 2015 :  09:37:12  Show Profile  Reply
I tested DoPrintPreviewDialog here with 6.2.1 and did not get any exceptions here and the dialog was displayed as expected. This has been working for some time now, so I suspect your problem is caused by old imageen files in your path or a problem in elsewhere with your code, possibly in some ImageEn event, or possibly a problem with the IDE.

Do you get the same exception when running a small demo with minimal code?
Do you only get the exception when running from the IDE?
Do you get the exception when executing the EXE outside of the IDE?

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

BMurdoch

USA
8 Posts

Posted - Dec 30 2015 :  12:26:40  Show Profile  Reply
Thanks Bill.

The problem occurs both inside and outside of the IDE. I've double-checked for stray DCU's and don't see any issues, though it is easy to miss one.

Looks like I'll be tracing into IE source code...
Go to Top of Page

xequte

38615 Posts

Posted - Dec 30 2015 :  13:16:47  Show Profile  Reply
Hi

Perhaps you could email us for the latest source. I have not seen this particular error, but we did make a fix to one that might be related.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

w2m

USA
1990 Posts

Posted - Dec 30 2015 :  14:34:58  Show Profile  Reply
I'd also check for imageen files in different folders... especially if the paths are in the IDE this can cause problems as well.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

BMurdoch

USA
8 Posts

Posted - Dec 30 2015 :  14:57:58  Show Profile  Reply
Sorry Nigel, I haven't put together a small test case yet. If it gets to that point then I will certainly send it over.
Go to Top of Page

xequte

38615 Posts

Posted - Jan 02 2016 :  13:55:03  Show Profile  Reply
Hi

Please just email us for the pre-release of v6.2.2 first, and test that.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

BMurdoch

USA
8 Posts

Posted - Jun 30 2016 :  17:40:08  Show Profile  Reply
I had put this problem on the back burner, but it's time to fix it now.

I just upgraded to ImageEN v6.3, and the error persists. I have tracked the error to this method:

procedure IEInitializeComboBox(AComboBox : TComboBox);
var
  TM : Windows.TTextMetric;
  iSize: Integer;
begin
  if AComboBox.Style = csOwnerDrawFixed then
  begin
    GetTextMetrics(AComboBox.Canvas.Handle, TM);
    iSize := GetSystemMetrics(SM_CYBORDER) * 2 + TM.tmHeight;
    if iSize > AComboBox.ItemHeight then
      AComboBox.ItemHeight := iSize;
  end;
end;


The error occurs on the call to GetTextMetrics - more precisely, evaluating ACombobox.Canvas.Handle results in a EInvalidOperation exception.

Any help on this would be appreciated.
Go to Top of Page

xequte

38615 Posts

Posted - Jun 30 2016 :  18:57:32  Show Profile  Reply
Hi

What version of Windows and Delphi are you using? Is AComboBox.Canvas.Handle nil at that time?


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

BMurdoch

USA
8 Posts

Posted - Jun 30 2016 :  20:26:35  Show Profile  Reply
Sorry, should have known to include those details - Delphi 5, Windows 7 and Windows Server 2012 (using RDP). Combobox and Canvas are both assigned - but strangely Handle gives the exception even when debugging and using tooltip evaluation. Since an HDC is just a longword, I would expect an unassigned Canvas.Handle to show a value of 0 - not raise an exception when it is evaluated.
Go to Top of Page

xequte

38615 Posts

Posted - Jul 03 2016 :  16:36:07  Show Profile  Reply
Hi

Unforutunately i cannot reproduce so I will wrap it in an exception block.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

BMurdoch

USA
8 Posts

Posted - Jul 03 2016 :  18:24:58  Show Profile  Reply
That is what I did as well. There seems to be no further impact of eating the exception, but I haven't testing with large fonts or high DPI, which I presume was the reason for this method in the first place.
Go to Top of Page

xequte

38615 Posts

Posted - Jul 03 2016 :  21:26:20  Show Profile  Reply
Yes, that code to ensure the drop down looks correct even if there are scaled fonts. You could try moving the IEInitializeComboBox call to FormShow.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: