Re: OT: XP Dual Monitor Detection

new topic     » goto parent     » topic index » view thread      » older message » newer message

Craig Welch wrote:
> 
> OtterDad wrote:
> > 
> > Under Windows XP, does anybody have a system call to detect if the user is 
> > using dual monitors? I have a resize routine that got too smart on itself 
> > and won�t allow you to save the window's position if it thinks that you're
> >
> > 'off the screen'. Unfortunately, that translates to off the primary screen 
> > only. Thanks!
> 
> How does it know that you're off the primary screen? 
> 
> Every program I write saves the x-y position of the window when it closes in
> a .ini file, and puts the window there next time it opens. My observation is
> that the co-ordinates simply treat all the screens as one big wide screen.
> Talking
> purely in terms of x-y co-ordinates, the system doesn't seem to care from
> primary
> or secondary.

my resize system compares getRect(Window or control) against getRect(Screen) 
to make sure user doesn't attempt to move or resize their objects position 
off screen. more than happy for improvement ideas. see below:

-- ====================================================================
global function my_getRect(atom local_hwnd)
    -- get rect dimensions and convert to {x,y,w,h}
    return xyxy2xywh(getRect(local_hwnd))
end function
-- ====================================================================
-- returns {0,0,screen_width,screen_height}
constant screen_pos = my_getRect(Screen)
debug_message("screen pos = " & sprint(screen_pos))
global procedure set_control_pos(atom local_hwnd, sequence local_pos,
    atom repaint)
    -- works to resize any window or control
    -- passed as (hwnd, {x,y,width,height}, repaint_boolean)

    -- check to make sure window is not "off the screen"
	if local_pos[pos_x] > screen_pos[pos_width] or
		local_pos[pos_y] > screen_pos[pos_height] then return end if

    -- ignore if silly values or minimized
    for i = 1 to 4 do if local_pos[i] < 0 then return end if end for

    setRect(local_hwnd, local_pos[pos_x], local_pos[pos_y],
    	local_pos[pos_width], local_pos[pos_height], repaint)
end procedure
-- ====================================================================


Yours, OtterDad

Don't sweat it -- it's not real life. It's only ones and zeroes. Gene Spafford

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu