[fpc-pascal] windows graph unit questions

James Richters james at productionautomation.net
Wed Aug 17 21:46:55 CEST 2016

Thank you for the help, Pierre!
 I am making some progress, but it I still have a few issues.  Here is where
I am at:

For issue #1 - getting rid of the title bar.... 
     Based on Pierre's information that there is a windows API call to get
rid of the titlebar, I did some searching and found that I can in fact hide
the title bar using these commands:

SetWindowLong(graphwindow, GWL_STYLE, 0);
ShowWindow(graphwindow, SW_SHOW);

However now I have two issues,  GetmaxX and getmaxY are still returning the
size that was available with the titlebar, so I don't know how bit the
screen really is.  I wrote the application to use getmaxX and getmaxy and
adjust itself to whatever size screen it is run on.  

The other issue is that it seems to have shifted the screen to the left and
up about 4pixels in each direction.. it's as if the upper left corner of the
screen is 4,4 instead of 0,0 so the top and left edge of my screen get cut

I suspect that perhaps there is a way I can put these commands inside the
graph unit before the getmaxx and getmaxy variables are created and it would
come out correctly, but I really don't know how and where that happens.

For issue #2 - changing the name of the graph window application...  This
has been Resolved! 
     Pierre was spot on!   I was able to change the name of the graph window
applications using the command:

setwindowtextA(graphwindow,'My Application Name Here');    

 If I can't figure out how to get rid of the windows title bar, at least
this is much more professional and makes it look like I did it on purpose :)

For issue #3 - getting rid of the command window 
   I'm still having this issue,   What happens is it opens the command
window then puts the graph application window on top of it.. at this point
everything looks and works fine, because you can't see the command window,
but in fact the command window is the active window where the keyboard is
going.   If I task switch out by hitting the windows key however, this
arrangement no longer works.. If I bring the graph application window back
to the active window, it will not respond to my keyboard, but if I bring the
command window back, then it does respond to the keyboard, but the command
window is now on top of the graph application window so I can't see what I'm

I did try {$apptype gui} and what happens is the program runs with no screen
whatsoever, neither the command window or the graph application window.   I
don't really understand what you mean by -WG option so I don't know how to
try that.
If I cannot get rid of the command window, is there some way to assign
keyboard input to the program to the graph application window when it is the
active window instead of the command window?  It's a bit of an issue because
even just clicking on the title bar of the graph application window makes
that the active window and now the program will not respond to the keyboard/

I really appreciate the help with this!

-----Original Message-----
From: fpc-pascal-bounces at lists.freepascal.org
[mailto:fpc-pascal-bounces at lists.freepascal.org] On Behalf Of Pierre Free
Sent: Wednesday, August 17, 2016 9:41 AM
To: 'FPC-Pascal users discussions' <fpc-pascal at lists.freepascal.org>
Subject: Re: [fpc-pascal] windows graph unit questions


the beauty about free open source is that you can search the sources:

> -----Message d'origine-----
> De : fpc-pascal-bounces at lists.freepascal.org [mailto:fpc-pascal- 
> bounces at lists.freepascal.org] De la part de James Richters Envoyé : 
> mercredi 17 août 2016 14:42 À : 'FPC-Pascal users discussions'
> Objet : [fpc-pascal] windows graph unit questions
> I have a few questions about using the graph unit with windows.
> 1.        Is there any way to get rid of the bar at the top that says 
> ‘graph window application’   I don’t need it or want it, I want the 
> user locked into my program full screen until they exit it
  I think that display/hiding title bar of a window is feasible with some
standard Windows API call, it might be forbidden for specific windows type,
but I don't think that we added anything special for this in the source
  I can't help you on this side, sorry.
> 2.       If there is no way to get rid of the bar at the top, Is there
> a way change the title of it to the name of my application instead of 
> ‘graph window application’ ?
Look for ‘graph window application’   in graph package:
Pierre at E6510-Muller cygwin-32 ~/pas/off-trunk/packages/graph $ grep -ir
'graph window application' .
./src/win32/graph.pp:    windowtitle : pchar = 'Graph window application';
Note here that windowtitle is an initialized variable, that that you can
change its value before calling InitGraph.

Find where windowtitle is used:
Pierre at E6510-Muller cygwin-32 ~/pas/off-trunk/packages/graph $ grep -riw
windowtitle .
./src/macosx/graph.pp: windowTitle:   CFStringRef;
./src/macosx/graph.pp:  windowTitle := CFCopyLocalizedString(titleKey, nil);
// 5
./src/macosx/graph.pp:  err := SetWindowTitleWithCFString (myMainWindow,
windowTitle); // 6
./src/macosx/graph.pp:  CFRelease (windowTitle);
./src/win32/graph.pp:    windowtitle : pchar = 'Graph window application';
ParentWindow:=CreateWindowA('FPCGraphWindowMain', windowtitle,
./src/win32/graph.pp:       hWindow:=CreateWindowA('FPCGraphWindow',

Here you see that the Windows version simply uses CreateWindowA Windows API
function, which means that you can use the Windows API function
SetWindowTextA to modify the title after starting (untested).
You will need the windows handle, but there is an interface variable called
GraphWindow that provides this for you.

> 3.       Is there any way I can make my program use only the graph
> interface, and not display the command window?
  Did you try 
{$apptype gui}
or -WG option?

> Thanks for any advice anyone has to address these thing

I hope this will help you,

fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org

More information about the fpc-pascal mailing list