How do you close the dos box automaticly, when your graphic screen quits? (GDI)?
Announcement
Collapse
No announcement yet.
How do you close the dos box automaticly?
Collapse
X
-
Originally posted by Lynn Wakefield View PostHow do you close the dos box automaticly, when your graphic screen quits?
In case you are running your program from an already opened CMD.EXE the Console window will stay open, what I would say is desirable. No need to close CMD.EXE programatically.
Regards
Albert„Let the machine do the dirty work.“
The Elements of Programming Style, Brian W. Kernighan, P. J. Plauger 1978
-
Lynn, it might be a good idea to clarify some preliminaries:- Are you starting the (your?) program from Explorer or from an already open CMD.EXE?
- If the latter situation applies, why would you need to close CMD.EXE? I wouldn't take it very well if an applications shuts down my Console window.
- If the program is doing a Sudoku puzzle using graphics, is there any reason for using PBCC? For doing mainly grahics PBWin would be the better solution.
Or did I get you wrong?
Albert„Let the machine do the dirty work.“
The Elements of Programming Style, Brian W. Kernighan, P. J. Plauger 1978
Comment
-
Albert, Albert!
PLEASE don't discourgage the newbies by suggesting they are using the wrong product!!!
Besides, I think PowerBASIC Inc. added the GRAPHICS stuff to the Console Compiler specifically to faciliate the creation of graphic screens. I'd have to call Florida to confirm this, but you could do that yourself.Michael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
-
Originally posted by Michael Mattias View PostBesides, I think PowerBASIC Inc. added the GRAPHICS stuff to the Console Compiler specifically to faciliate the creation of graphic screens. I'd have to call Florida to confirm this, but you could do that yourself.Sincerely,
Steve Rossell
PowerBASIC Staff
Comment
-
maybe I got the wrong program (PBCC 4.04) to do what I want. If you run the program Cool.exe that comes as an example, when you close the program the dos window also disappears. That is what I want. But I also want to pull a number over to the Sudoku grid and drop it there. Did I buy the wrong product? Thanks guys
Comment
-
Hi Lynn,
First, you can easily do the same type of graphics programming in PBCC that you can in PBWin. The only difference is that PBWin has a GRAPHIC CONTROL in addition to GRAPHIC WINDOWS. A GRAPHIC CONTROL is a control that is displayed on a dialog box, you could have multiple controls (text boxes, combo boxes, graphic controls, etc.) on one dialog box. If you are not familiar with event driven programming that PBWin uses or are coming from a DOS background then PBCC is the right choice.
As Albert said, if you start the program from the command prompt (Dos Box) then when the program exits control is returned to the command prompt, it does not close. If you start the program from outside of the command line (Windows Explorer, desktop shortcut, etc.) then the command prompt will close after the program exits. I can only guess that you are running cool.exe from outside of the command line, but are starting your program from within the command prompt?Sincerely,
Steve Rossell
PowerBASIC Staff
Comment
-
Originally posted by Lynn Wakefield View PostI just click on the program name Sudoku.exe, my graphic window comes up then I click on the upper right X then the window closes but Not the DOS box. ThanksSincerely,
Steve Rossell
PowerBASIC Staff
Comment
-
I am double clicking cool.exe to run and I am also double clicking Sudoku.exe to run. Now the cool.exe closes all windows when you quit but Sudoku.exe makes you close the dos window that is left. Did I buy the wrong product for what I want to do?
I have a Sudoku puzzle in the middle of the screen with numbers 1-9 in a row at the top. I want to click on a number and drag it to a spot on the sudoku grid. That will set that grid spot to that number. When I get done I want to click on a row of numbers at the bottom of the screen and have the program print a Sudoku grid with the possibilities of that number on the printed grid.
Am I over my head?
Thanks, Lynn from Helena, MT
Comment
-
Originally posted by Pierre Bellisle View PostLynn, try... PostMessage CONSHNDL, %WM_CLOSE, 0, 0
I used #CONSOLE OFF like Mel Bishop did in another post, but it locks the program (still running in the background).
I start my program from a shortcut on the desktop.
Comment
-
Lynn,
For example, in the PBCC Cool.bas demo program,
make it the last line in the WinMain function.
This will force the "DOS box" to close if you
started Cool.exe from a command prompt.
I must admit that I'm not certain that my answer fit with you question.
If it's not what you want to acheive then maybe
you can rephrase your question so I can have
a better idea of what you want to acheive.
[ADDED]
Is the sodoku code avaiable somewhere ?Last edited by Pierre Bellisle; 25 Jan 2008, 03:29 PM.
Comment
-
Originally posted by Pierre Bellisle View PostLynn,
For example, in the PBCC Cool.bas demo program,
make it the last line in the WinMain function.
This will force the "DOS box" to close if you
started Cool.exe from a command prompt.
I must admit that I'm not certain that my answer fit with you question.
If it's not what you want to acheive then maybe
you can rephrase your question so I can have
a better idea of what you want to acheive.
[ADDED]
Is the sodoku code avaiable somewhere ?
Here's a copy & paste of my code:
Code:#COMPILE EXE '1/26/08 #DIM ALL '#CONSOLE OFF '#INCLUDE "WIN32API.INC" DECLARE SUB Make_Sudoku_Grid DECLARE SUB Get_Mouse_Position FUNCTION PBMAIN AS LONG CONSOLE SET LOC 1,1 CONSOLE SET SCREEN 58.5,126 CONSOLE SET FOCUS 'LOCATE 1,1 'PRINT "testing" Make_Sudoku_Grid 'PostMessage CONSHNDL, %WM_CLOSE,0,0 Get_Mouse_Position WAITKEY$ END FUNCTION SUB Make_Sudoku_Grid LOCAL hwin AS DWORD 'GRAPHIC WINDOW "Sudoku Puzzle", Horiz_start , Vert_start, Width, Height GRAPHIC WINDOW "Sudoku Puzzle", 0 , 0, 1018, 706 TO hWin 'window location GRAPHIC ATTACH hwin, 0 GRAPHIC WIDTH 3 GRAPHIC BOX (300, 150) - (700, 500) 'GRAPHIC BOX (Upper Left horiz corner, Upper Left vert corner) - '(Lower Right horiz corner, Lower Right vert corner) SLEEP 50 GRAPHIC LINE (430,499)-(430,150) 'Vert Line 3 GRAPHIC LINE (570,499)-(570,150) 'Vert Line 6 GRAPHIC LINE (300,270)-(700,270) 'Horiz line 3 GRAPHIC LINE (300,390)-(700,390) 'Horiz line 6 GRAPHIC WIDTH 1 GRAPHIC LINE (345,499)-(345,150) 'Vert Line 1 GRAPHIC LINE (390,499)-(390,150) 'Vert Line 2 GRAPHIC LINE (480,499)-(480,150) 'Vert Line 4 GRAPHIC LINE (525,499)-(525,150) 'Vert Line 5 GRAPHIC LINE (615,499)-(615,150) 'Vert Line 7 GRAPHIC LINE (660,499)-(660,150) 'Vert Line 8 GRAPHIC LINE (300,190)-(700,190) 'Horiz line 1 GRAPHIC LINE (300,230)-(700,230) 'Horiz line 2 GRAPHIC LINE (300,310)-(700,310) 'Horiz line 4 GRAPHIC LINE (300,350)-(700,350) 'Horiz line 5 GRAPHIC LINE (300,427)-(700,427) 'Horiz line 7 GRAPHIC LINE (300,462)-(700,462) 'Horiz line 8 'Top boxes 'GRAPHIC BOX (Upper Left horiz corner, Upper Left vert corner) - '(Lower Right horiz corner, Lower Right vert corner) GRAPHIC BOX (60, 60) - (100, 100),20 GRAPHIC BOX (160, 60) - (200, 100),20 GRAPHIC BOX (260, 60) - (300, 100),20 GRAPHIC BOX (360, 60) - (400, 100),20 GRAPHIC BOX (460, 60) - (500, 100),20 GRAPHIC BOX (560, 60) - (600, 100),20 GRAPHIC BOX (660, 60) - (700, 100),20 GRAPHIC BOX (760, 60) - (800, 100),20 GRAPHIC BOX (860, 60) - (900, 100),20 'Bottom boxes 'GRAPHIC BOX (Upper Left horiz corner, Upper Left vert corner) - '(Lower Right horiz corner, Lower Right vert corner) GRAPHIC BOX (60, 600) - (100, 640),20 GRAPHIC BOX (160, 600) - (200, 640),20 GRAPHIC BOX (260, 600) - (300, 640),20 GRAPHIC BOX (360, 600) - (400, 640),20 GRAPHIC BOX (460, 600) - (500, 640),20 GRAPHIC BOX (560, 600) - (600, 640),20 GRAPHIC BOX (660, 600) - (700, 640),20 GRAPHIC BOX (760, 600) - (800, 640),20 GRAPHIC BOX (860, 600) - (900, 640),20 GRAPHIC SET POS (240,20) GRAPHIC FONT "Times New Roman", 18, 7 'size = 18 points, bold + Italic + underline = (1+2+4) GRAPHIC PRINT "Click on a number then click on the Sudoku grid" GRAPHIC SET POS (220,650) GRAPHIC PRINT "Click on a number to print that numbers possibilities" GRAPHIC FONT "Times New Roman", 18, 1 'points=18,1 = bold GRAPHIC SET POS (74,67) : GRAPHIC PRINT "1" GRAPHIC SET POS (174,67) : GRAPHIC PRINT "2" GRAPHIC SET POS (274,67) : GRAPHIC PRINT "3" GRAPHIC SET POS (374,67) : GRAPHIC PRINT "4" GRAPHIC SET POS (474,67) : GRAPHIC PRINT "5" GRAPHIC SET POS (574,67) : GRAPHIC PRINT "6" GRAPHIC SET POS (674,67) : GRAPHIC PRINT "7" GRAPHIC SET POS (774,67) : GRAPHIC PRINT "8" GRAPHIC SET POS (874,67) : GRAPHIC PRINT "9" SLEEP 50 GRAPHIC SET POS (74,606) : GRAPHIC PRINT "1" GRAPHIC SET POS (174,606) : GRAPHIC PRINT "2" GRAPHICp?s= POS (274,606) : GRAPHIC PRINT "3" GRAPHIC SET POS (374,606) : GRAPHIC PRINT "4" GRAPHIC SET POS (474,606) : GRAPHIC PRINT "5" GRAPHIC SET POS (574,606) : GRAPHIC PRINT "6" GRAPHIC SET POS (674,606) : GRAPHIC PRINT "7" GRAPHIC SET POS (774,606) : GRAPHIC PRINT "8" GRAPHIC SET POS (874,606) : GRAPHIC PRINT "9" PRINT "Hit any key to close window....." WAITKEY$ GRAPHIC WINDOW END END SUB SUB Get_Mouse_Position LOCAL I AS STRING LOCAL x,y AS LONG MOUSE 3,DOUBLE,DOWN MOUSE ON DO i$ = WAITKEY$ SELECT CASE LEN(i$) CASE 1 PRINT i$;" key pressed" CASE 2 PRINT "Alt+key pressed" CASE 4 SELECT CASE ASC(i$, 3) CASE 2 PRINT "Double-click"; CASE 4 PRINT "Single-click"; END SELECT PRINT " at"; MOUSEY;",";MOUSEX END SELECT LOOP UNTIL I$ = CHR$(27) 'ESC key END SUB
Thanks for any help, Lynn
Comment
-
Hi,
I have been faced with a similar problem.
This is how I solved it.
local gwin as long
Create graphics window etc
Embed this expression or similar in the main loop.
IF IsWindow(gwin) = 0 THEN EXIT FUNCTION
The IsWindow function determines whether the specified window handle identifies an existing window.
RegardsGary Barnes
The Control Key
If you are not part of the solution
then you are either a gas, solid, plasma or some other form of matter.
Comment
-
Lynn,
I did a mix of your code and
some subclassed code that Steve posted in another thread.
This should give you another way of doing thing.
Code will work with PBCC 4.00 to 4.04, look for %PB_REVISION to see how 4.04 is handled...
Code:#COMPILE EXE '#CC 4.04# #DIM ALL #CONSOLE OFF 'Added line, this can be used... #INCLUDE "Win32Api.Inc" GLOBAL hWin AS DWORD GLOBAL WinProc AS DWORD GLOBAL Finished AS LONG '______________________________________________________________________________ FUNCTION SubclassedProc(BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS DWORD) AS LONG 'This is the function that is called whenever a key or 'mouse click is detected in the graphics window LOCAL Buffer AS STRING STATIC OldBuffer AS STRING SELECT CASE wMsg CASE %WM_KEYUP IF CHR$(WPARAM) = "X" THEN Finished = 1 ELSE Buffer = "Chr: " & CHR$(WPARAM) & " (Ascii " & FORMAT$(wparam) & ") GOSUB GraphicPrint END IF CASE %WM_MOUSEMOVE Buffer = "Move mouse: " & STR$(LO(WORD, lParam)) & "," & STR$(HI(WORD, lParam)) GOSUB GraphicPrint CASE %WM_LBUTTONDOWN Buffer = "Left mouse down: " & STR$(LO(WORD, lParam)) & "," & STR$(HI(WORD, lParam)) GOSUB GraphicPrint CASE %WM_LBUTTONUP Buffer = "Left mouse up: " & STR$(LO(WORD, lParam)) & "," & STR$(HI(WORD, lParam)) GOSUB GraphicPrint CASE %WM_RBUTTONDOWN Buffer = "Right mouse down: " & STR$(LO(WORD, lParam)) & "," & STR$(HI(WORD, lParam)) GOSUB GraphicPrint CASE %WM_RBUTTONUP Buffer = "Right mouse up: " & STR$(LO(WORD, lParam)) & "," & STR$(HI(WORD, lParam)) GOSUB GraphicPrint CASE %WM_DESTROY Finished = %TRUE 'Quit if graphic Windows close END SELECT FUNCTION = CallWindowProc(WinProc, hWnd, wMsg, wParam, lParam) EXIT FUNCTION '--------------------------------------------------------------- GraphicPrint: 'Graphic print routine STDOUT Buffer GRAPHIC ATTACH hWin, 0, REDRAW GRAPHIC FONT "Times New Roman", 18, 1 IF INSTR(Buffer, "mouse") THEN GRAPHIC SET POS(5, 200) ELSE GRAPHIC SET POS(5, 250) END IF GRAPHIC COLOR GetSysColor(%COLOR_BTNFACE) 'Set text color to background color GRAPHIC PRINT OldBuffer 'Result is erasing old text IF INSTR(Buffer, "mouse") THEN GRAPHIC SET POS(5, 200) ELSE GRAPHIC SET POS(5, 250) END IF GRAPHIC COLOR %BLUE GRAPHIC PRINT Buffer GRAPHIC REDRAW OldBuffer = Buffer 'Seem's to be needed for key trap 'only when "#Console on" and compiler is 4.04 'after focus goes from cosole to graphic IF %PB_REVISION >= &H404 THEN 'If PCCC is at least 4.04 IF GetForegroundWindow = hWin THEN GRAPHIC SET FOCUS END IF END IF RETURN END FUNCTION '______________________________________________________________________________ FUNCTION PBMAIN LOCAL hProc AS DWORD GRAPHIC WINDOW "Sudoku Puzzle - PBRevision: " & HEX$(%PB_REVISION), 0 , 0, 1018, 706 TO hWin IF %PB_REVISION >= &H404 THEN 'If PCCC is at least 4.04 'Retreive the handle to the static control on the graphic window hProc = GetWindow(hWin, %GW_CHILD) ELSE 'Retreive the handle to the graphic window hProc = hWin END IF 'This function subclasses the Graphic, 'which means that any key or mouse presses 'will cause the SubclassedProc Callback function to be called WinProc = SetWindowLong(hProc, %GWL_WNDPROC, CODEPTR(SubclassedProc)) GRAPHIC ATTACH hwin, 0 GRAPHIC WIDTH 3 GRAPHIC BOX (300, 150) - (700, 500) GRAPHIC LINE (430, 499)-(430,150) 'Vert Line 3 GRAPHIC LINE (570, 499)-(570,150) 'Vert Line 6 GRAPHIC LINE (300, 270)-(700,270) 'Horiz line 3 GRAPHIC LINE (300, 390)-(700,390) 'Horiz line 6 GRAPHIC WIDTH 1 GRAPHIC LINE (345, 499)-(345,150) 'Vert Line 1 GRAPHIC LINE (390, 499)-(390,150) 'Vert Line 2 GRAPHIC LINE (480, 499)-(480,150) 'Vert Line 4 GRAPHIC LINE (525, 499)-(525,150) 'Vert Line 5 GRAPHIC LINE (615, 499)-(615,150) 'Vert Line 7 GRAPHIC LINE (660, 499)-(660,150) 'Vert Line 8 GRAPHIC LINE (300, 190)-(700,190) 'Horiz line 1 GRAPHIC LINE (300, 230)-(700,230) 'Horiz line 2 GRAPHIC LINE (300, 310)-(700,310) 'Horiz line 4 GRAPHIC LINE (300, 350)-(700,350) 'Horiz line 5 GRAPHIC LINE (300, 427)-(700,427) 'Horiz line 7 GRAPHIC LINE (300, 462)-(700,462) 'Horiz line 8 GRAPHIC BOX (60, 60) - (100, 100),20 GRAPHIC BOX (160, 60) - (200, 100),20 GRAPHIC BOX (260, 60) - (300, 100),20 GRAPHIC BOX (360, 60) - (400, 100),20 GRAPHIC BOX (460, 60) - (500, 100),20 GRAPHIC BOX (560, 60) - (600, 100),20 GRAPHIC BOX (660, 60) - (700, 100),20 GRAPHIC BOX (760, 60) - (800, 100),20 GRAPHIC BOX (860, 60) - (900, 100),20 GRAPHIC BOX ( 60, 600) - (100, 640),20 GRAPHIC BOX (160, 600) - (200, 640),20 GRAPHIC BOX (260, 600) - (300, 640),20 GRAPHIC BOX (360, 600) - (400, 640),20 GRAPHIC BOX (460, 600) - (500, 640),20 GRAPHIC BOX (560, 600) - (600, 640),20 GRAPHIC BOX (660, 600) - (700, 640),20 GRAPHIC BOX (760, 600) - (800, 640),20 GRAPHIC BOX (860, 600) - (900, 640),20 GRAPHIC SET POS (240,20) GRAPHIC FONT "Times New Roman", 18, 7 GRAPHIC PRINT "Click on a number then click on the Sudoku grid" GRAPHIC SET POS (220,650) GRAPHIC PRINT "Click on a number to print that numbers possibilities" GRAPHIC FONT "Times New Roman", 18, 1 GRAPHIC SET POS ( 74,67) : GRAPHIC PRINT "1" GRAPHIC SET POS ( 174,67) : GRAPHIC PRINT "2" GRAPHIC SET POS ( 274,67) : GRAPHIC PRINT "3" GRAPHIC SET POS ( 374,67) : GRAPHIC PRINT "4" GRAPHIC SET POS ( 474,67) : GRAPHIC PRINT "5" GRAPHIC SET POS ( 574,67) : GRAPHIC PRINT "6" GRAPHIC SET POS ( 674,67) : GRAPHIC PRINT "7" GRAPHIC SET POS ( 774,67) : GRAPHIC PRINT "8" GRAPHIC SET POS ( 874,67) : GRAPHIC PRINT "9" GRAPHIC SET POS ( 74,606) : GRAPHIC PRINT "1" GRAPHIC SET POS (174,606) : GRAPHIC PRINT "2" GRAPHIC SET POS (274,606) : GRAPHIC PRINT "3" GRAPHIC SET POS (374,606) : GRAPHIC PRINT "4" GRAPHIC SET POS (474,606) : GRAPHIC PRINT "5" GRAPHIC SET POS (574,606) : GRAPHIC PRINT "6" GRAPHIC SET POS (674,606) : GRAPHIC PRINT "7" GRAPHIC SET POS (774,606) : GRAPHIC PRINT "8" GRAPHIC SET POS (874,606) : GRAPHIC PRINT "9" GRAPHIC SET POS(5, 250) GRAPHIC COLOR %BLUE GRAPHIC PRINT "Press a key..." IF %PB_REVISION >= &H404 THEN 'If PCCC is at least 4.04 GRAPHIC SET FOCUS END IF DO 'Loop until an X is pressed on the graphic window SLEEP 10 LOOP UNTIL Finished 'Set the graphics window to use the original Callback routine SetWindowLong(hProc, %GWL_WNDPROC, WinProc) GRAPHIC ATTACH hWin, 0 GRAPHIC WINDOW END END FUNCTION '______________________________________________________________________________ '
Last edited by Pierre Bellisle; 28 Jan 2008, 07:03 PM.
Comment
Comment