3 Questions: 2 Easy and one hard

Just starting out? Need help? Post your questions and find answers here.
TerryHough
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 6:51 pm
Location: NC, USA
Contact:

Post by TerryHough »

Code: Select all

If OpenWindow(1,300,400,400,100,#PB_Window_SystemMenu,"AppThatClosesTheOther")
  CreateGadgetList(WindowID())
  ButtonGadget(0,10,10,100,25,"Close other")
  Repeat
    ev=WaitWindowEvent()
    If ev=#PB_Event_Gadget
      PostMessage_(FindWindow_(0,"AppToBeClosed"),#WM_CLOSE,0,0)
    EndIf
  Until ev=#PB_Event_CloseWindow
EndIf
@PB

Found myself needing something similar today. Is there any way to
force a DOS Window to close automatically? Your routine tries to
close a DOS window but Windows prompts for a user reply to force the
close on the DOS window. Maybe there is a way to force the whole thing?

Terry
cecilcheah
Enthusiast
Enthusiast
Posts: 168
Joined: Wed Jun 04, 2003 8:44 am
Location: Switzerland

Post by cecilcheah »

Anyone can answer my question?

Hi there

The 2 easy questions are resolved. Thanks for the help.

However after downloading the ownGadget_Example.pb, i run into an error when compiling the example.

Code: Select all

Procedure paint(gadget) 
  GetWindowRect_(gadget,rc.rect) 
  x=GetGadgetItemState(0,#OG_HPosition) 
  y=GetGadgetItemState(0,#OG_VPosition) 
  DrawingMode(0) 
  Box(0,0,rc\right,rc\bottom,RGB(255,0,100)) 
  LineXY(0,y,rc\right,y,RGB(0,255,0)) 
  LineXY(x,0,x,rc\bottom,RGB(0,255,0)) 
EndProcedure 



Error: Constant not found: #OG_HPosition

What is the constant value for #OG_HPosition?

Cecil[/code]
TerryHough
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 6:51 pm
Location: NC, USA
Contact:

Post by TerryHough »

@Cecil

I wasn't familiar with this library, so I just downloaded, unzipped, and
installed it. Seems the example compiles and work fine on PB v3.92.

Perhaps you didn't get the library installed correctly.

The file OWNGADGET should be placed in the
\purebasic\purelibraries\userlibraries folder

The file OWNGADGET.res should be placed in the
\purebasic\residents folder.

Then restart PB and try the example. Works for me.

Terry
cecilcheah
Enthusiast
Enthusiast
Posts: 168
Joined: Wed Jun 04, 2003 8:44 am
Location: Switzerland

Post by cecilcheah »

That is it, thanks

Your quiestion: Can you not use KillWindowProcess to close the dos prompt?

Cecil
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

cecil,

Did you copy OwnGadget into purebasic\PureLibraries\UserLibraries and OwnGadget.RES into purebasic\Residents?
cecilcheah
Enthusiast
Enthusiast
Posts: 168
Joined: Wed Jun 04, 2003 8:44 am
Location: Switzerland

Post by cecilcheah »

Yes, i did copy them to the folders, but it is still giving me the error, the same error.

??

Cecil
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> Windows prompts for a user reply to force the close on the DOS window

There is no such prompt on Windows XP -- the DOS window just closes as
expected. Which version of Windows are you running?

> Maybe there is a way to force the whole thing?

Two things I can think of:

(1) Send a keystroke to confirm the prompt, eg. if the prompt requires a Yes
response then send a Y keystroke when the prompt appears. Messy. :)

(2) Terminate the DOS window process, as mentioned by Cecil.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
cecilcheah
Enthusiast
Enthusiast
Posts: 168
Joined: Wed Jun 04, 2003 8:44 am
Location: Switzerland

Post by cecilcheah »

yes, just try it with some code. MS Dos window close with WM_Close with no problem and no prompt.

Do you want some code?

Cecil
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

Works OK here.

It looks like the problem is with the residency file. Don't know whats going wrong.

Try adding the following at the top, so you can at least get an idea of what it does.

Code: Select all

#OG_HPosition = 9
#OG_VPosition = 4
TerryHough
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 6:51 pm
Location: NC, USA
Contact:

Post by TerryHough »

PB wrote:> Windows prompts for a user reply to force the close on the DOS window

There is no such prompt on Windows XP -- the DOS window just closes as
expected. Which version of Windows are you running?
@PB

Win98SE - don't be mad at me, I am forced to live with it for important reasons.

@cecilcheah
Yes, I would love to see your code. If you know it works with DOS windows on Win98SE, that is even better. Or I can just try it.

Thanks everyone,
Terry
cecilcheah
Enthusiast
Enthusiast
Posts: 168
Joined: Wed Jun 04, 2003 8:44 am
Location: Switzerland

Post by cecilcheah »

Hi there

Here is the code. Be careful, it will close all DOS Window. So maybe you have to look for Window Text with "MS Dos Prompt" to close the right DOS window.

Code: Select all

window = OpenWindow (0, 0, 0, 320, 200, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "Close all DOS window") 
If CreateGadgetList(WindowID()) 
   ButtonGadget(1, 50,30, 128,22,"Close DOS") 
    

 Repeat 
   event=WaitWindowEvent() 
      Select EventGadgetID() 
        Case 1;Post Message 
            hWnd = FindWindow_(0, "MS-Dos Prompt")
            PostMessage_(hWnd ,#wm_close,0,0)   
      EndSelect 
Until event=#pb_event_Closewindow 

Endif
Someone may help you more here.

Cecil
TerryHough
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 6:51 pm
Location: NC, USA
Contact:

Post by TerryHough »

cecilcheah wrote:Here is the code. Be careful, it will close all DOS Window. So maybe you have to look for Window Text with "MS Dos Prompt" to close the right DOS window.

Cecil
Thanks Cecil. You code is very similar to that posted above. And they
both work to close a "MS-DOS Prompt" job on WinXP and Win98SE. But
if DOS box is actually running a program, Win98SE responds differently
from WinXP.

If that "MS-DOS Prompt" is actually running some sort of DOS program
then it does not work under Win98SE. It does attempt to close the
MS-DOS job, but then Windows gives you a message saying something
like this one.

Code: Select all

PostMessage_(FindWindow_(0,"MS-DOS Prompt - Main"),#WM_CLOSE,0,0) 
results in

Image

I can't find a way to pass that message box a Y to force the close.

Oddly, WinXP does this differently since it never shows the MS-DOS Prompt - part of the job name. The command there is

Code: Select all

PostMessage_(FindWindow_(0,"Main"),#WM_CLOSE,0,0) 
and it successfully closes the job.

So, I am still searching. Thanks for your help.

Terry
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> I can't find a way to pass that message box a Y to force the close

This works (when the message box has the focus):

Code: Select all

keybd_event_(#VK_Y,0,0,0) : keybd_event_(#VK_Y,0,#KEYEVENTF_KEYUP,0)
Is there a DOS app that comes native with Win98 that I can run and test?
I'll find a way for you to do it, but I need a DOS app to run under Win98.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
cecilcheah
Enthusiast
Enthusiast
Posts: 168
Joined: Wed Jun 04, 2003 8:44 am
Location: Switzerland

Post by cecilcheah »

Can we try to ping an IP address, when it is still running, you can test it?

I am still having problems with the Own Gadget application. I put the constants in as written, now it says the structure does not exist.

Code: Select all


If CreateGadgetList(WindowID())
 owngadget\.owngadgetstruct
 owngadget\name="TEST"
 owngadget\vmin=0
 owngadget\vmax=191
 owngadget\vpage=10
 owngadget\vpos=95
 owngadget\hmin=0
 owngadget\hmax=191
 owngadget\hpage=10
 owngadget\hpos=95
 owngadget\PaintProc=@paint()
 ;owngadget\Size=@size()
 ;owngadget\HScrollProc=@hscroll()
 ;owngadget\VScrollProc=@vscroll()
 owngadget\MouseProc=@mouse()
 owngadget\posawaremouse=#True
 owngadget\backcolor=RGB(255,0,100)
 owngadget\cursor=0;#IDC_SIZEALL
Error:
Structure not found: .owngadgetstruct
I thought the structure should be owngadget, not owngadgetstruct?

When i replace .owngadgetstruct with \owngadgetstruct

another error:
The variable does not have a 'Strucutre'
With this line marked:
owngadget\.owngadgetstruct

Also, when i install the IE Tool, install runs ok. But when i try to click the Pure Basic button in IE Explorer, i got this error:
can't find 'confid.dat'
???

Cecil[/code]
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

cecil,

the structure looks like this:

Code: Select all

Structure owngadgetstruct
  name.s
  backcolor.l
  cursor.l
  flags.l
  hmin.l
  hmax.l
  hpage.l
  hpos.l
  vmin.l
  vmax.l
  vpage.l
  vpos.l
  hscrollproc.l
  vscrollproc.l
  sizeproc.l
  PaintProc.l
  MouseProc.l
  posawaremouse.l
EndStructure
You really need to look into why the compiler isn't picking up the OwnGadget.res.
Post Reply