Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cobol Window Handle For Screen Display

Status
Not open for further replies.

amitjainbls

Programmer
Mar 7, 2008
10
0
0
US
I am developing a code on NETCobol and have following issues.

1.When i ran the program it didnt throw a big screen, so i set the environment variable during run time as @scrnsize(160,80). I got the full screen but i am seeing that the character based screen is just concentrated at one-quarter of the screen and rest are all blank. Then i tried to increse the font size,but no help all the characters overlapped with each other occupying the same quarter area.

2. I want to disable the title bar like maximize,minimize,and exit butons.


For the second issue i got information from one of my friend that i need to do the following

i) i need to have the window handle on the console window
ii) i need to call the API GetSystemMenu


But, i dont know to get the window handle,how to call API GetSystemMenu .

Is there someone who could provide me out sample code of executing the above window handling programs or explain me the process how to carry out the operation.


Any help is appreciated.
 
2. I want to disable the title bar like maximize,minimize,and exit butons.

A lot depends on what you mean by this...you want the title bar gone?
 
Oh well. Here's both as written in Fujitsu COBOL 3.0 (NetCOBOL should be similar). The big problem was figuring out relevant API calls. Using GetForegroundWindow is a little dangerous in terms of having something else come up right as your program is running, but should be OK 95% of the time.

Code:
 @OPTIONS MAIN,DLOAD,NOALPHAL
 IDENTIFICATION DIVISION.
* Test program for removing the titlebar & move option from console.
 PROGRAM-ID. WINSCRN.
 ENVIRONMENT DIVISION.
 DATA DIVISION.
 WORKING-STORAGE SECTION.
 01  WS-VARIABLES.
     04  WS-CHOICE             PIC X VALUE 'A'.
         88 WS-CHOICES         VALUES ARE 'y' 'n' 'Y' 'N'.
         88 REMOVE-TITLEBAR    VALUES ARE 'y' 'Y'.
     04  WS-WINHANDLE          PIC S9(9) COMP-5.
     04  WS-SYSMENUHANDLE      PIC S9(9) COMP-5.
     04  WS-WINSTYLE           PIC S9(9) COMP-5.
* SOME STANDARD CONSTANTS.  NO-SYSMENU IS STANDARD WINDOW CONTROL XOR WS_SYSMENU
     04  GWL-STYLE             PIC S9(9) COMP-5 VALUE -16.
     04  NO-SYSMENU            PIC S9(9) COMP-5 VALUE 381878272.
     04  SC-SIZE               PIC S9(9) COMP-5 VALUE 61440.
     04  SC-MOVE               PIC S9(9) COMP-5 VALUE 61456.
     04  SC-MINIMIZE           PIC S9(9) COMP-5 VALUE 61472.
     04  SC-MAXIMIZE           PIC S9(9) COMP-5 VALUE 61488.
     04  SC-CLOSE              PIC S9(9) COMP-5 VALUE 61536.
     04  MF-ENABLED            PIC S9(9) COMP-5 VALUE 0.
     04  MF-BYCOMMAND          PIC S9(9) COMP-5 VALUE 0.
     04  MF-GRAYED             PIC S9(9) COMP-5 VALUE 1.
     04  MF-DISABLED           PIC S9(9) COMP-5 VALUE 2.
     04  DUMMY-CHAR            PIC X.
 
 PROCEDURE DIVISION.
 0000-START SECTION.
     PERFORM UNTIL WS-CHOICES
       DISPLAY "REMOVE THE TITLEBAR? (Y/N)"
       ACCEPT WS-CHOICE FROM CONSOLE  
     END-PERFORM.
     IF REMOVE-TITLEBAR
       PERFORM 1000-INIT
       PERFORM 3000-DISABLE-MOVE
       DISPLAY "MOVE OPTION SHOULD BE GONE NOW.  PRESS ENTER"
CEPT DUMMY-CHAR FROM CONSOLE
       PERFORM 2000-REMOVE-SYSMENU
       DISPLAY "SYSTEM MENU ICONS SHOULD BE GONE NOW.  PRESS ENTER"
       ACCEPT DUMMY-CHAR FROM CONSOLE
     END-IF.
     GOBACK.

 1000-INIT SECTION.
* GET A FEW SYSTEM HANDLES TO WORK WITH IN THE OTHER PARTS * WHERE WE ACTUALLY SET THINGS.
     CALL "GetForegroundWindow" WITH STDCALL LINKAGE
     END-CALL.
     MOVE RETURN-CODE TO WS-WINHANDLE.
     CALL "GetSystemMenu" WITH STDCALL LINKAGE
        USING BY VALUE WS-WINHANDLE
              BY VALUE 0
     END-CALL.
     MOVE RETURN-CODE TO WS-SYSMENUHANDLE.
     CALL "GetWindowLongA" WITH STDCALL LINKAGE 
        USING BY VALUE WS-WINHANDLE
              BY VALUE GWL-STYLE
     END-CALL.
     MOVE RETURN-CODE TO WS-WINSTYLE.

 2000-REMOVE-SYSMENU SECTION.
* REMOVES THE SYSTEM MENU OFF THE TITLEBAR
     CALL "SetWindowLongA" WITH STDCALL LINKAGE
        USING BY VALUE WS-WINHANDLE
              BY VALUE GWL-STYLE
              BY VALUE NO-SYSMENU
     END-CALL.
     CALL "DrawMenuBar" WITH STDCALL LINKAGE
        USING BY VALUE WS-WINHANDLE
     END-CALL.         

 3000-DISABLE-MOVE SECTION.
* DISABLES THE MOVE MENU OPTION
     CALL "DeleteMenu" WITH STDCALL LINKAGE
        USING BY VALUE WS-SYSMENUHANDLE
              BY VALUE SC-MOVE
              BY VALUE MF-BYCOMMAND
     END-CALL.
     CALL "DrawMenuBar" WITH STDCALL LINKAGE
        USING BY VALUE WS-WINHANDLE
     END-CALL.

The corresponding COBOL85.CBR file required to run this:
Code:
[WINSCRN]
@IconName=COB85EXE
@ScrnSize=(80,24)
@CnslWinSize=(80,24)
@CnslBufLine=100
@WinCloseMsg=ON
@EnvSetWindow=USE
@AllFileExclusive=NO
@CBR_PrintTextPosition=TYPE1
@CBR_TextAlign=BOTTOM
[WINSCRN.ENTRY]
GetForegroundWindow=USER32.DLL
GetSystemMenu=USER32.DLL
GetWindowLongA=USER32.DLL
SetWindowLongA=USER32.DLL
EnableMenuItem=USER32.DLL
DrawMenuBar=USER32.DLL
DeleteMenu=USER32.DLL
 
i set the environment variable during run time as @scrnsize(160,80). I got the full screen but i am seeing that the character based screen is just concentrated at one-quarter of the screen and rest are all blank. Then i tried to increse the font size,but no help all the characters overlapped with each other occupying the same quarter area.

On this, it seems CnslWinSize is what you want to set (assuming things haven't changed again from Fujitsu 3.0).

As far as the character screen goes, it appears that the assumption was made that each character would only be a certain size. Increase it beyond a point and you get what you observed.
 
Thanks Glenn For your quick response.
After getting this window handle routine how do i call this routine in my program.Could you please get down the changes to this sample of My program as follows:

IDENTIFICATION DIVISION.
PROGRAM-ID. DATE-CHECK-PROGRAM.
AUTHOR.AMIT.
* The Date program
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 CURR-DATE PIC X(6).
SCREEN SECTION.
01 BLANK-SCREEN BLANK SCREEN.
01 PROGRAM-SCREEN.
03 LINE 1 COLUMN 1 PIC X(6) FROM CURR-DATE
HIGHLIGHT FOREGROUND-COLOR 4.
03 COLUMN 18 VALUE 'A C C O U N T P R O C E S S I N G '
HIGHLIGHT FOREGROUND-COLOR 4.
03 COLUMN 72 VALUE '*DATE-CHECK-PROGRAM*' HIGHLIGHT FOREGROUND-COLOR 4.
03 LINE 2 COLUMN 18 VALUE
'==== WINDOWS XP VERSION ===='
HIGHLIGHT FOREGROUND-COLOR 5.
03 LINE 9 COLUMN 1 VALUE ' MAKE SURE YOUR CAPS LOCK
- ' KEY IS ON BEFORE CONTINUING!!!!!! '
HIGHLIGHT FOREGROUND-COLOR 3.
03 LINE 12 COLUMN 20 VALUE 'CURRENT WEEK-ENDING DATE IS '
HIGHLIGHT FOREGROUND-COLOR 5.
03 LINE 14 COLUMN 20 VALUE
'IF INCORRECT CALL ME!!!!!! '
HIGHLIGHT FOREGROUND-COLOR 3.
03 LINE 20 COLUMN 15 VALUE
'F10 OR END/ENTER TO CONTINUE; F8 = END PROGRAM'
HIGHLIGHT FOREGROUND-COLOR 6.
PROCEDURE DIVISION.
ACCEPT CURR-DATE FROM DATE.
DISPLAY BLANK-SCREEN.
DISPLAY PROGRAM-SCREEN.
ACCEPT PROGRAM-SCREEN.
TERM-PROC.
EXIT PROGRAM.


And for the second query regarding the size,I have set @CnslWinSize=(160,80)and @scrnsize(160,80)but characters are still occupying the quarter of the top left hand screen and remaining portion are blank.I want to have the characters displayed uniformly throught out the screen so that it looks good.
For this do i need to have my screen descriptions (Pic clause) change from (80,24) to (160,80)format for each field ?
And also the strange is happening when i change the @scrnfont(arial,20).Many of the letters of the screen are overlapping with each other.

Please help me out from the above problems.

 
Glenn,

Can you atleast provide me any sample piece of code for calling this routine from any program.

It would be a great help for me.

Thanks
 
I answered your original question #1 already.

As for your question #2, page 288 and page 328 of your manual would be a great start.
 
glenn999,

I tried to call the following in the above program after procedure division:

CALL "WINHANDLE" WITH STDCALL LINKAGE USING BY VALUE
PGM-STAT RETURNING PGM-STAT ON OVERFLOW DISPLAY 'ERROR CALL'
END-CALL.

But i am facing error on overflow condition diplaying 'error call'

Asssuming that i am getting PGM-STAT Value 00

Any help is appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top