Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Windows
 Charting and Real-Time Graphics Tools for Windows
 "Cannot create pen" error on redraw
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

TonyGrayDSI

14 Posts

Posted - 18 Sep 2005 :  17:29:00  Show Profile  Reply with Quote
I'm drawing multiple graphs in a grid on a single page. That page is nested in a VB picturebox in a way similar to what's done in the MDIDemo example project.

I'm finding that I often get a Msgbox with the title "SERIOUS ERROR" and the message "Cannot create pen. Would you like to continue?" followed by program exit if I click on the 'No' button, or the same message again if I select 'Yes'. I thought it was associated with the window resize, but it happens during repainting even if no resizing of the window is attempted.

I haven't been able to learn much about this message. Any info anyone has on what it means and why it might be coming up would be greatly appreciated.

Many thanks,
Tony Gray

Edited by - TonyGrayDSI on 18 Sep 2005 22:20:27

TonyGrayDSI

14 Posts

Posted - 18 Sep 2005 :  20:13:09  Show Profile  Reply with Quote
After more investigation, it turns out that this is exclusively associated with my use of WGSetMultiColors(), which I can avoid. I'll have a closer look at the parameters I'm suppling to see if that's the problem.
Tony
Go to Top of Page

TonyGrayDSI

14 Posts

Posted - 20 Sep 2005 :  12:37:08  Show Profile  Reply with Quote
I have confirmed this is a problem by adding a call to SetMultiColors to the BIGDEMO example program and getting the same error as follows:

1) Change the page type of pPageDesc2 to MM_PROPORT so the graph resizes with the window
2) Create a form level array for colours with NUMP2 entries. In the MakeData routine, dimension it and populate it with colour values:
ColourArray(i) = WGGetRGBColor(C_BLACK + i Mod (C_OFFWHITE - C_BLACK))
3) add the call to SetMultiColors right after the creation of the scatter plot in DrawP2G1:
' Scatter Plot - data set 2
hObj = WGScatterPlot(pGrDesc, hdc, hDataSet2, MK_ASTERISK, C_LIGHTBLUE, 7, MKS_EMPTY, False)
WGSetMultiColors pGrDesc, hObj, True, ColourArray(0)

To get the error, you need to trigger lots of redraws (hundreds of them). The best way to do this is to turn on 'Show window contents while dragging' in your screen properties, grab the bottom corner of the window frame, then drag it around in circles until it blows up. Moving the mouse quickly, it takes me about four seconds.

It looks like something is being allocated inside the paint routine that isn't being released if the multicolour feature is in use. I've already rewritten my code to avoid using this routine, so I don't need a workaround - just posting in case it helps you guys.

Edited by - TonyGrayDSI on 20 Sep 2005 12:49:26
Go to Top of Page

quinncurtis

1164 Posts

Posted - 20 Sep 2005 :  15:03:45  Show Profile  Reply with Quote
If you have the example, zip it and send it to support@quinn-curtis.com and we will take a look at it.
Go to Top of Page

TonyGrayDSI

14 Posts

Posted - 20 Sep 2005 :  18:48:08  Show Profile  Reply with Quote
It's on its way. BTW, use the 'START PAGE 2' button to launch the problem graph. If you use 'START ALL PAGES' then it will launch without the MM_PROPORT flag and so won't redraw continuously when dragging the window frame to resize.

All the best,
Tony Gray

Edited by - TonyGrayDSI on 20 Sep 2005 18:48:50
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07