[fpc-pascal] ptcgraph issues

James Richters james at productionautomation.net
Fri May 19 03:28:26 CEST 2017


I've been able to figure out a few workarounds for issues with ptcgraph,

 

To prevent scaling and dropped pixels, I have come up with 3 workarounds,
not ideal but they could work:

 

1.	Positon the window so the title is off the top of the screen with

               SetWindowPos(Graphicwindow,HWND_TOP,-8,-31,0,0,SWP_NoSize);

               I cannot use maximize with this and the coordinates for the
top left corner might be different on different machines.  

               I think my development computer is strange because of having
3 monitors

 

2.	Leave the title bar on with the window sized correctly, but set my
own variables to not use the bottom of the window which

is off the screen so it looks right with

SetWindowPos(Graphicwindow,HWND_TOP,-8,0,0,0,SWP_NoSize);

                WinMax_Y:=GetMaxY-31;  

               Then I use WinMax_Y instead of GetMaxY

               This has the same problem as option #1 in that the
coordinates for the top left of the screen might not be the same on other
machines

               I haven't been able to find a really good solution to keeping
the titlebar and having the window the right size and being able to use
maximize. 

               I think the only way will be for ptcgraph to create the
window sized so maximized it fits completely on the screen with the titlebar
and then report a smaller GetMaxY

 

3.	Turn off the title bar, then reset the size of the window to be
correct with:

         SetWindowLongPTR(graphicwindow, GWL_STYLE, 0);

         SetWindowPos(Graphicwindow,HWND_TOP,0,0,GetMaxX+1,GetMaxY+1,0);

         ShowWindow(graphicwindow, SW_Maximize);

If you don't want the titlebar then this is the best solution because the
Maximize will make it fit properly on the screen regardless of 

How it is configured.

 

 

The only other issue I am having is the problem where task switching with
ALT-Tab causes the keyboard not to respond to ptccrt anymore.  I have
narrowed this down a bit,  it's NOT task switching in general that causes
this, it's specifically ALT-TAB that causes it.   I was also mistaken about
it only happening with full screen, this happens all the time, no matter how
the window is configured.  If I hit the windows logo key and task switch
that way , there is no problem when I go back to the ptcgraph window, also
if I get back to my console window with 

         ShowWindow(ConsoleWindow,SW_show);

         SetActiveWindow(ConsoleWindow);

         SetForegroundWindow(ConsoleWindow);

And alt tab from the console window, then no matter what method I use to get
back to the ptcgraph window, even alt-tab,  it's no problem and ptccrt
responds to the keyboard.

 

So that's where I'm at with this.  It would be great if better solutions can
be found for these issues.  The main thing for me is the ALT-Tab issue,
especially if I go with option 3 above where I won't have a minimize button.
Alt-tab is a really big habit because as I mentioned before, most of the
computer I run this on don't have a mouse attached.   If I could disable
alt-tab from this window somehow, then at least I wouldn't accidentally
break keyboard response to the ptcgraph window, but I don't know how I could
do that either.

 

James

 

 

From: fpc-pascal [mailto:fpc-pascal-bounces at lists.freepascal.org] On Behalf
Of James Richters
Sent: Wednesday, May 17, 2017 4:19 PM
To: 'FPC-Pascal users discussions' <fpc-pascal at lists.freepascal.org>
Subject: [fpc-pascal] ptcgraph issues

 

I'm having a few issues with ptcgraph.  

 

The main issue is that it's not correctly reporting the actual size of the
available area to use inside the ptcgraph window.  It's reporting my full
screen resolution, but that amount of space is not really available due to
the title bar.   The window that is generated is a 1919x1176 window, but it
won't fit on the screen due to the title bar, so I hit maximize, now it fits
on the screen but it's too small.   I generate my screen based off the
GetMaxX and GetMaxY functions and my screen based on GetMaxX being 1919 and
GetMaxY being 1199 should not fit inside a window that fills the screen but
with a border around it and a title bar at the top, but it is being scaled
down to fit.  This scaling is causing pixels to be dropped.   If I force
GetMaxX and GetMaxY to be the correct numbers of 1919x1176 which is what the
graph unit reports, It just leaves a gap at the bottom of the screen the
same width as the title bar, and still scales the screen from 1919x1199 down
to fit in the available space of 1919x1176 making some pixels drop.    I
have tried maximizing the screen with ShowWindow(graphwindow, SW_Maximize);
before I use GetMaxX and GetMaxY, but they still report the full screen
size.   

 I can get the screen to look right with no scaling and no dropped pixels if
I use SetWindowPos(Graphicwindow,HWND_TOP,-8,-32,0,0,swp_nosize); to
position the window so the title bar is off the top of the screen,  but as
you can see my X and Y coordinates are screwy. it's something to do with my
multiple monitors why top left is not 0,0  So I have no way of knowing what
to set this to on any given system, so it's not really a solution at all. it
just proves what the problem is.

 

So I thought I would force it to be full screen, to see if I could prevent
the scaling.. but that also has issues.  I figured if it looks right
shifting the title bar off the top of the screen, then simply shutting off
the title bar should fix it, but I could not get that to work either.  There
are 2 ways I can get full screen without the title bar that I can think of.
I can just shut off all windows styles with    SetWindowLongPTR(graphwindow,
GWL_STYLE, 0);   but this has the opposite problem,  If I draw a rectangle
from 0,0 to GetMaxX,GetMaxY, I should get a rectangle that barely fits on
the screen, but I don't see anything because it's way too big.  I have to
draw a rectangle from 8,8 to GetMaxX-8,GetMaxY-8 to get it to fit on the
screen.    However with this method of getting rid of the titlebar, I can
taskswitch out and back in with no issues, my keyboard still works and if I
taskswitch out, it just puts other windows on top of this, so I can always
click on it to make it active again.  The scaling causes things to not look
right.

 

 

If I get the full screen by setting fullscreengraph := True;  then it does
seem to report stop scaling and now everything fits correctly on the screen,
however. this has it's own issues.   For some reason when I use this to
obtain full screen, it does not task switch anywhere near as gracefully as
using SetWindowLongPTR(graphwindow, GWL_STYLE, 0);    If I task switch to
anything else, the graph window disappears completely, so now I have nothing
to click on to get it back, and using ShowWindow() to get it back takes a
very long time.  Then when I eventually get the window back, it no longer
responds to the keyboard. 

 

James

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170518/63283530/attachment.html>


More information about the fpc-pascal mailing list