1. Simplest way to bring console to front

Hello,

I'm wondering what the simplest way to bring the console window
to the front is when working in Windows (XP) and the console opens 
behind the main window...any ideas?  Sometimes it's a pain even
when double clicking a file in Explorer and a console opens behind
the Explorer file window.  Sometimes you dont even see the console at
all...in fact it often looks like the program didnt even run until
you minimize (or move aside) the Explorer file view window.


Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » topic index » view message » categorize

2. Re: Simplest way to bring console to front

Al Getz wrote:
> 
> Hello,
> 
> I'm wondering what the simplest way to bring the console window
> to the front is when working in Windows (XP) and the console opens 
> behind the main window...any ideas?  Sometimes it's a pain even
> when double clicking a file in Explorer and a console opens behind
> the Explorer file window.  Sometimes you dont even see the console at
> all...in fact it often looks like the program didnt even run until
> you minimize (or move aside) the Explorer file view window.
> 
> 
> Take care,
> Al
> 
> And, good luck with your Euphoria programming!
> 
> My bumper sticker: "I brake for LED's"
> 

Hello AL,

I had the same problem with Windows 2000 and fixed it by minimizing the

Explorer or whatever Window was in the way and using clickPointerLeft() over

the console Window.  I have never used XP. So I don't know.

Don Cole
SF

new topic     » goto parent     » topic index » view message » categorize

3. Re: Simplest way to bring console to front

don cole wrote:
> 
> Al Getz wrote:
> > 
> > Hello,
> > 
> > I'm wondering what the simplest way to bring the console window
> > to the front is when working in Windows (XP) and the console opens 
> > behind the main window...any ideas?  Sometimes it's a pain even
> > when double clicking a file in Explorer and a console opens behind
> > the Explorer file window.  Sometimes you dont even see the console at
> > all...in fact it often looks like the program didnt even run until
> > you minimize (or move aside) the Explorer file view window.
> > 
> > 
> > Take care,
> > Al
> > 
> > And, good luck with your Euphoria programming!
> > 
> > My bumper sticker: "I brake for LED's"
> > 
> 
> Hello AL,
> 
> I had the same problem with Windows 2000 and fixed it by minimizing the
> 
> Explorer or whatever Window was in the way and using clickPointerLeft() over
> 
> the console Window.  I have never used XP. So I don't know.
> 
> Don Cole
> SF
> 

Hi Don,

What do you mean by clickPointerLeft() ?


Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

4. Re: Simplest way to bring console to front

Al Getz wrote:

> What do you mean by clickPointerLeft() ?

It's in the Win32lib.ew Docs under Mouse.

In my case the Console Window just happens to shows up right behind the 

Button in the Main Window that I just clicked . So there is no need for me 

to move the Mouse. In some cases however it maybe necessary to:

(after minimizing the Main Window)

[1] find the location of the Console Window.

[2] move the Mouse pointer to that location.

[3] clickPointerLeft() 

I know you said a simple way. I'm not sure if this would fit into that 

category or not.

Don Cole
SF

new topic     » goto parent     » topic index » view message » categorize

5. Re: Simplest way to bring console to front

For Al or anybody else who is interested,

don cole wrote:

> 
> [1] find the location of the Console Window.
> 

 Further notes on finding the location of the Console Window.

I used Window.ew by Thomas Parslow (PatRat) in the Archives.

He identifies the handle by the Window Caption.

  Now here's the trick, when writing and testing your code the Console Window

Caption is "f:\Euphoria\BIN\exw.exe" (or wherever you put your BIN folder).

Once the program is bound the Console Caption becomes "MyProgram.exe".

So you must change your code in the final bind.

Hope this makes sense,

Don Cole
SF

new topic     » goto parent     » topic index » view message » categorize

6. Re: Simplest way to bring console to front

Thanks Don, i'll look into this...


Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

7. Re: Simplest way to bring console to front

The API function GetConsoleWindow() will return a handle to the console
associated with the current process. Once you have this, there are a number of
functions that may be used to bring the window to the front, such as
BringWindowToTop(). Unfortunately, GetConsoleWindow() is available only on
Win2000 and later.

Larry Miller

new topic     » goto parent     » topic index » view message » categorize

8. Re: Simplest way to bring console to front

Larry Miller wrote:
> 
> The API function GetConsoleWindow() will return a handle to the console
> associated
> with the current process. Once you have this, there are a number of functions
> that
> may be used to bring the window to the front, such as BringWindowToTop().
> Unfortunately,
> GetConsoleWindow() is available only on Win2000 and later.
> 
> Larry Miller
> 

Thanks Larry.  You reminded me there is also GetConsoleTitle().


Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

9. Re: Simplest way to bring console to front

Larry Miller wrote:
> 
> The API function GetConsoleWindow() will return a handle to the console
> associated
> with the current process. Once you have this, there are a number of functions
> that
> may be used to bring the window to the front, such as BringWindowToTop().
> Unfortunately,
> GetConsoleWindow() is available only on Win2000 and later.
> 
> Larry Miller
> 

Where do you get GetConsoleWindow() from ? That would save me a lot of trouble.

Or better yet how do you convert an API funtion to an Euphoria function?

Thanks,

Don Cole
SF

new topic     » goto parent     » topic index » view message » categorize

10. Re: Simplest way to bring console to front

Also I forgot to ask where would I get a list of all the API functions
associated with Windows 2000?

Don Cole
SF

new topic     » goto parent     » topic index » view message » categorize

11. Re: Simplest way to bring console to front

GetConsoleWindow is documented on MSDN  
http://msdn.microsoft.com/library/

A search for "GetConsoleWindow" will give a link to the functions documentation.

The program below will show how GetConsoleWindow() can be used with euphoria

include dll.e
include get.e

atom Kernel32,xGetConsoleWindow

	Kernel32=open_dll("kernel32.dll")
	xGetConsoleWindow=define_c_func(Kernel32,"GetConsoleWindow",{},C_ULONG)

	puts(1,"\n")	--Open console window
	?c_func(xGetConsoleWindow,{})
	?wait_key()


This program will cause a Euphoria run-time error on an OS prior to Windows2000.

See the Euphoria docs for further details.

MSDN has a listing of which functions were introduced with Win2000 but it is
rarely necessary to know this. With rare exceptions, functions introduced with
Windows 95 will still work on Windows2000 and XP. The MSDN documentation
indicates the system requirements for each function.

Larry Miller

new topic     » goto parent     » topic index » view message » categorize

12. Re: Simplest way to bring console to front

don cole wrote:
> 
> Also I forgot to ask where would I get a list of all the API functions
> associated with Windows 2000?
> 
> Don Cole
> SF
> 

Hi there Don,


As Larry had mentioned, there are functions listed on the Microsoft
site, in the online library, but you could also order a CD from them
that installs on your computer.  There used to be an older form of
the documentation too, about 10 megabytes long, that had lots of
info on using the API function calls.  Im not sure anymore where this
is available online so perhaps someone might remember.  This latter
help file has most of the functions used for Win95 and almost none for
Win2000 and up, but it's still very useful and it's a small file
compared to the whole SDK documentation on the CD.

Once you find an API function you want to wrap to Euphoria, you have
to understand the conversion between the C data types and how Euphoria
uses atoms.  What this means is that sometimes you'll have to poke
the data into memory before you can call the API function.
For example, looking in the documentation for "ClientToScreen" we'd
find this:

  BOOL ClientToScreen(
    HWND  hWnd,	// window handle for source coordinates
    LPPOINT  lpPoint 	// address of structure containing screen coordinates
   );

  Parameters:
  hWnd
    Identifies the window whose client area is used for the conversion. 
  lpPoint
Points to a POINT structure that contains the client coordinates to be
    converted. The new screen coordinates are copied into this structure if the
    function succeeds.
  Return Value
    If the function succeeds, the return value is TRUE.
    If the function fails, the return value is FALSE.

We have to know that a HWND type wraps to a Euphoria type C_POINTER,
and that the LPPOINT type wraps to a Euphoria C_POINTER too, but before
we can call this function we also have to know that LPPOINT struct is
8 bytes long, and HWND type is 4 bytes.  This means we have to poke
the LPPOINT struct before we can call this function.
We also have to know what return type to specify for Euphoria.
We can find out what dll this function is in by looking in the docs too.

STEP 1: Link to the functions dll (if it's not linked already)
  constant user32=open_dll("user32.dll")
STEP 2: Link to the function name in that dll
xClientToScreen = define_c_func(user32, "ClientToScreen", {C_POINTER,
    C_POINTER}, C_LONG)
STEP 3: We're almost ready to call this function, but first we must prepare the
data:
    --assume hWnd is the handle of our window that's already been created...
atom lpPoint --we need an atom for the point struct so we can allocate
    memory
    lpPoint-allocate(8) --a point struct is 8 bytes long (two 4 byte numbers)   
    --now load the point struct in memory with the actual points x and y:
    poke4(lpPoint,{x,y})
    --ok, now we have the hWnd and the point struct is loaded so we can call it:
    atom bool
    bool=c_func(xClientToScreen,{hWnd,lpPoint})
    --Lastly, we check the return value of 'bool' to see if the function
    --succeeded.
    --Knowing this function modifies the 'point' on return, if the function
    --succeeded then the new value of the point will be what we wanted all
    --along, but we must 'peek' it to obtain it...
    atom newx, newy
    newx=peek4s(lpPoint) --get the new x value
    newy=peek4s(lpPoint+4) --get the new y value
    free(lpPoint)
    --note we used peek4s because the C point struct is defined as
    --two LONG's.  If it had been defined as two ULONG's we would
    --have used peek4u instead.  Using peek4s means the two values
    --will be 'signed' values (could be plus or minus).


It's been a while since i wrote everything out like this so i hope
i got it all correct smile

Oh yeah, there are a few examples in my 'Help' program in the archive too.

If this seems like a lot you're right, but usually you wrap each
function to be used in a simpler way so you can just call one function
when you need to use that API function.  For example, for ClientToScreen
we could have created a function that takes a sequence (x and y) and
returns a sequence (newx, newy) something like this:

  global function ClientToScreen(atom hWnd, sequence xy)
--declare atoms, poke x and y, call API function, peek new x and y, free
    struct
    .
    .
    return {x,y}
  end function


I hope this helps a little Don...


Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

13. Re: Simplest way to bring console to front

Thank you Larry for the code. I have a program that bounces back and forth

between WINDOWS and DOS that it be very useful for.

And Al I may have bitten off more than I can chew. Thank God we don't have

to go outside the standard Windows Library very often. I'm saving your reply

for further study.

Don Cole
SF

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu