April 30, 2024, 08:06:02 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Dialog doesn't come to the top

Started by TexasPete, May 09, 2010, 05:16:50 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

TexasPete

I have several windows that need to stay visible at all times I have set these windows to the topmost.  I am tying in a module for a dialog . The dialog comes in behind the windows where it cannot be seen.  I thought that dialogs were supposed to come to the top for viewing.  On the language I am translating from this is what happens if I call a dialog. I am beginning to wonder if I am going about this correctly at all. Any experience with CB would be helpful.

Thanks
Texas Pete

aurelCB


TexasPete

I tried to set the dialog to topmost and it did not take the command. Should the same topmost routine work for the dialog to?


SetWindowPos(PageOptions,@HWND_TOPMOST,0,0,0,0,@SWP_NOMOVE|@SWP_NOSIZE)



The above works on the other windows. This is the first time I used it on a dialog.
Texas Pete

LarryMc

Appears you are using the wrong flag, since you already have other windows with the topmost flag set.

From the windows SDK:
QuoteHWND_TOP
Places the window at the top of the Z order.
HWND_TOPMOST
Places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

TexasPete

May 09, 2010, 07:01:53 AM #4 Last Edit: May 09, 2010, 07:19:14 AM by TexasPete
Larry , I just want to make sure I understand.

When I want a window to Stay on the screen permantly , I want to Use HWND_TOPMOST.  IF I WANT THE WINDOW TO SIMPLE COME TO THE TOP AND DO AWAY WITH IT WHEN i AM DONE, HWND_TOP.
In the z order the last window on top would be the last window called or the last z number. Is that right?

Texas Pete

BY the way do I need to set a constant for HWND_TOP

LarryMc

Without having seen any actual code to see what you're really trying to accomplish it is hard to tell if I'm addressing your specific needs.

Normally people only have one window open (and showing) at a time in a program.  When they need another window to "popup", so to speak, to enter data, find a file, etc they use a modal dialog.  A modal dialog opens on top and doesn't let you interact with any other window until you close the modal dialog.

In my Visual Designer (as well as my chart and button designers) I open a bunch of windows at the beginning in "hidden" mode.  Meaning they are there, I can read/write to their controls but you can't see them.  Then depending on what "mode" I'm in I "show" the appropriate window.  When I'm through with that mode and move to another mode I hide the current window and show another one.  All of this is done without ever using the topmost flag.

Most of those windows that I hide and show have dialogs associated with them.  EB\CB dialogs(when opened in modal mode) have the topmost flag set internally). 

The point is; in all the programming I've done I've only had one situation where I have opened a window and needed to set the topmost flag.

Also, when using multiple windows you have to be aware of the parent(s) of those windows or you can get some results that may not be what you want.

Since you are already using SetWindowPos(PageOptions,@HWND_TOPMOST,0,0,0,0,@SWP_NOMOVE|@SWP_NOSIZE)I would think that you already have @HWND_TOP defined but with no code i can't tell.
But to the best of my knowledge it is not a predefined constant in CB.


If I could see(or better understand) what you are REALLY trying to accomplish I could possibly give you a better response.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

TexasPete

May 09, 2010, 04:31:49 PM #6 Last Edit: May 09, 2010, 04:36:33 PM by TexasPete
Larry , Below are the synopsis of my code settings, For my windows. I searched the forum to set a const for the "HWND_TOP".  I did not find the correct number to assign to the const.


setid "SWP_NOMOVE",2
setid "SWP_NOSIZE",1
setid "HWND_TOP",1
setid "HWND_TOPMOST",-1
setid "HWND_NOTOPMOST",-2
setid "WS_EX_PALETTEWINDOW",256
'=======================================The Windows==================================
Window win1,26,185,ScreenWidth,ScreenHeight-35,wstyle1,0,"Main Scrolling Window",main1
'if win1 >0  then MESSAGEBOX win1, "MADE IT","Created window 1!"
' ---------------------sets the back Screen color of the scroll window
Window win2,0,0,MainWidth,MainHeight,wstyle2,win1,"Child Window ",window2:SETWINDOWCOLOR win2,rgb(150,200,140)
'if win2 >0  then MESSAGEBOX win2, "MADE IT","Created window 1!"

'SETWINDOWCOLOR win1,rgb(254,240,197)
'-----------------------------MainWidth=ScreenWidth:MainHeight=ScreenHeight
'----Second window child ----This is the window all text and graphics are written to-------
Window win3,0,187,30,ScreenHeight-35,wstyle2,0,"Child Window ",window3:SETWINDOWCOLOR win3,rgb(255,255,255)
'---------------------LeftSide Window-----------Graphic-----Numbers
' ------------Across the top Graphic Window-----or Horizontal graphics number---------------------
Window win4,29,162,1400,26,wstyle2,0,"Child Window ",window4:SETWINDOWCOLOR win4,rgb(255,255,255)
'-------------Little box window --------------
Window win5,0,162,31,27,wstyle2,0,"Child Window ",window5:SETWINDOWCOLOR win5,rgb(255,255,255)
DIALOG PageOptions,0,0,320,575,0x80C80080,0,"Options",OptionsPage
'====================Setting windows to top====================================
SetWindowPos(win1,@HWND_TOPMOST,0,0,0,0,@SWP_NOMOVE|@SWP_NOSIZE)
SetWindowPos(win2,@HWND_TOPMOST,0,0,0,0,@SWP_NOMOVE|@SWP_NOSIZE)
SetWindowPos(win3,@HWND_TOPMOST,0,0,0,0,@SWP_NOMOVE|@SWP_NOSIZE)
SetWindowPos(win4,@HWND_TOPMOST,0,0,0,0,@SWP_NOMOVE|@SWP_NOSIZE)
SetWindowPos(win5,@HWND_TOPMOST,0,0,0,0,@SWP_NOMOVE|@SWP_NOSIZE)
SetWindowPos(PageOptions,@HWND_TOP,0,0,0,0,@SWP_NOSIZE)

'================================



Except for the Dialog , I am drawing to these windows, so I chose windows instead of dialog because I need to be able to draw to the windows. The Dialog was simply used for some switches to switch something on or off.
Should I have used "@HWND_TOP" instead OF "@HWND_TOPMOST". I NEED THE WINDOW " MAIN" THRU " WIN5" TO STAY VISIBLE AT ALL TIMES. I THINK i only need to Declare the correct constant for "@HWND_TOP" in order to accomplish what I am trying to do. I Like your idea of making all the windows and then hiding them until you need them.  You could do that with the other language I used but most people didn't.
I did not want the first five windows to to move so I used "@SWP_NOMOVE".


Any suggestions or insight will be appreciated.  The code for this project is long, so I pulled out the settings that I had rather than you looking at 5,000 lines.

Thanks
Texas Pete









LarryMc

From the dimensions of your windows I can't tell and that there is only one window that has a parent window I still can't figure out what you are trying to accomplish.

I was trying to dummy up your code to show you how to fix it but I still don't have enough information.

I have some questions:
How are you setting the values of ScreenWidth,ScreenHeight and/or what are they set to?
How are you setting the values of MainWidth,MainHeight and/or what are they set to?
When you say you are 'drawing' to the windows you mean lines, circles, etc and not text; right?
You say all 5 windows need to be displayed all the time.  From some of you code it also appears you want then not to move.
   Is that true?  Also that you don't want their size changed;right?

Are you intending window win1 to be a scrolling window that contains win2?
And win3,win4,and win5 share screen space with win1?

feed me the correct info and I'll see if I can get you over the hump.

LarryMc




LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

This should help you a little, I think.
Copy it to a blank (new) file and run it.


setid "WM_SYSCOMMAND", = 0x112
setid "SC_CLOSE", = 0xF060
setid "SC_MAXIMIZE", = 0xF030
setid "SC_MOVE", = 0xF010
setid "SC_MINIMIZE", 0xF020

def main,win1,win2,win3,win4,win5:window
def PageOptions:dialog
def ScreenWidth,ScreenHeight:int
def wstyle1,wstyle2,wstyle3,wstyle4,wstyle5:int
def MainWidth,MainHeight:int
def X,Y,W,H:int
wstyle1=@VSCROLL
wstyle2=0
GETSCREENSIZE ScreenWidth,ScreenHeight
MainWidth=1024:MainHeight=728
'=======================================The Windows==================================
Window main,0,0,ScreenWidth,ScreenHeight,0,0,"Main Program Window",main0
getClientSize main,X,Y,W,H

Window win1,26,185,ScreenWidth-26,ScreenHeight-185-24,wstyle1,main,"Main Scrolling Window",window1
SETWINDOWCOLOR win1,rgb(254,240,197)
getClientSize win1,X,Y,W,H
MainWidth=w:MainHeight=H
' ---------------------sets the back Screen color of the scroll window
Window win2,0,0,MainWidth,MainHeight,wstyle2,win1,"Child Window 2 ",window2
SETWINDOWCOLOR win2,rgb(150,200,140)

CONTROL win2,"B,Open dialog,25,75,150,20,@TABSTOP,1"

'----Second window child ----This is the window all text and graphics are written to-------
Window win3,0,185,25,ScreenHeight-185,wstyle2,main,"Child Window 3",window3
SETWINDOWCOLOR win3,rgb(255,0,255)
'---------------------LeftSide Window-----------Graphic-----Numbers
' ------------Across the top Graphic Window-----or Horizontal graphics number---------------------
Window win4,26,0,ScreenWidth-26,184,wstyle2,main,"Child Window 4",window4
SETWINDOWCOLOR win4,rgb(255,255,255)
'-------------Little box window --------------
Window win5,0,0,25,184,wstyle2,main,"Child Window 5",window5
SETWINDOWCOLOR win5,rgb(255,0,0)


DIALOG PageOptions,0,0,320,575,0x80C80080,main,"Options",OptionsPage
CONTROL PageOptions,"B,close dialog,25,75,150,20,@TABSTOP,1"

'================================
run=1
WAITUNTIL run=0
CLOSEWINDOW WIN5
CLOSEWINDOW WIN4
CLOSEWINDOW WIN3
CLOSEWINDOW WIN2
CLOSEWINDOW win1
CLOSEWINDOW main
end

SUB main0
SELECT @CLASS
  CASE @IDCLOSEWINDOW
    run=0
ENDSELECT
RETURN

SUB window1
SELECT @CLASS
case @WM_SYSCOMMAND
if (@CODE & 0xfff0)=@SC_CLOSE then return 1
if (@CODE & 0xfff0)=@SC_MOVE then return 1
if (@CODE & 0xfff0)=@SC_MAXIMIZE then return 1
if (@CODE & 0xfff0)=@SC_MINIMIZE then return 1
CASE @IDCLOSEWINDOW
    run=0
ENDSELECT
RETURN

SUB window2
SELECT @CLASS
case @WM_SYSCOMMAND
if (@CODE & 0xfff0)=@SC_CLOSE then return 1
if (@CODE & 0xfff0)=@SC_MOVE then return 1
if (@CODE & 0xfff0)=@SC_MAXIMIZE then return 1
if (@CODE & 0xfff0)=@SC_MINIMIZE then return 1
CASE @IDCLOSEWINDOW
    run=0
case @IDCONTROL
select @CONTROLID
case 1
domodal PageOptions
endselect
ENDSELECT
RETURN

SUB window3
SELECT @CLASS
case @WM_SYSCOMMAND
if (@CODE & 0xfff0)=@SC_CLOSE then return 1
if (@CODE & 0xfff0)=@SC_MOVE then return 1
if (@CODE & 0xfff0)=@SC_MAXIMIZE then return 1
if (@CODE & 0xfff0)=@SC_MINIMIZE then return 1
CASE @IDCLOSEWINDOW
    run=0
ENDSELECT
RETURN

SUB window4
SELECT @CLASS
case @WM_SYSCOMMAND
if (@CODE & 0xfff0)=@SC_CLOSE then return 1
if (@CODE & 0xfff0)=@SC_MOVE then return 1
if (@CODE & 0xfff0)=@SC_MAXIMIZE then return 1
if (@CODE & 0xfff0)=@SC_MINIMIZE then return 1
CASE @IDCLOSEWINDOW
    run=0
ENDSELECT
RETURN

SUB window5
SELECT @CLASS
case @WM_SYSCOMMAND
if (@CODE & 0xfff0)=@SC_CLOSE then return 1
if (@CODE & 0xfff0)=@SC_MOVE then return 1
if (@CODE & 0xfff0)=@SC_MAXIMIZE then return 1
if (@CODE & 0xfff0)=@SC_MINIMIZE then return 1
CASE @IDCLOSEWINDOW
    run=0
ENDSELECT
RETURN

sub OptionsPage
select @CLASS
case @IDCONTROL
select @CONTROLID
case 1
closedialog PageOptions,@IDOK
endselect
'all controls should be initialized in response to @IDINITDIALOG
case @IDINITDIALOG
CENTERWINDOW PageOptions

endselect
return


LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

TexasPete

Larry , You were able to get all the windows on the screen without Hwnd_Top or Topmost. This is basically what I did in the other language. I am not familar with "WM_SYSCommand" . All the example that I had found in the Ib files. I assume  that HWND_TOp or topmost is rarely needed. I was making it harder than it actually was.

I will Study and get back to you.
Thanks
Texas Pete

LarryMc

Quote from: TexasPete on May 10, 2010, 05:47:06 AM
I am not familar with "WM_SYSCommand" .
It's one of the 100's(or 1,000's) of messages that are sent in the Windows OS.
I learned the trick of using that one from Sapero(I think).

Your problem was primarily due to having "separate, isolated" windows.

I made an overall application window I called main.
all the other windows are children of main except the one that is a child of a child of main because you are incorporating a scrolling window.

Another way to do what you are doing is to create all the children as captionless windows(that's what I usually do.).
Then the closing/dragging/sizing is no longer an issue.  If you still wanted the look of captions you can put a static control at the top of the child windows that is as wide as the windows but with a diffent color background.

Some people use MDI windows for what you are doing but I haven't had a lot of luck getting them to do exactly what I want; but I know it is just me.

LarryMc

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

TexasPete

I will relook at what I have . I had them set as child windows of main once.  I was still having some difficulty's and that is why they are in there present form. I went to microsoft to download a page on the commands and What they should be numerically set to.
I new there were lots of commands at microsoft. I don't have the memory to remember them all. I was unable to find a easy list of what to set the id numbers two. I will reset my windows.
Every time I open a new window it should come to the top is that correct?

Thanks
Texas Pete

LarryMc

when you open a window it will come to the top(have focus) unless there are windows already opened that have been set to topmost.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

TexasPete

Larry, That is the way I thought it should work. The  "TopMOst" command screwed up my thinking.  This has given me a better understanding of how windows work. I looked at your example and reset my windows, Now they are starting to behave as they
should. I am resetting the dialogs to be a child of the the Main window. The dialog started coming to the top. I am trying to call the dialog using domodal. The dialog comes up. The checkboxs all come up blank.  I used the SetState commands under"@IDINITDIALOG" Which is what I am supposed to do I thought. However, the check boxes all come up blank. When calling a child dialog using domodal , Where should you update the checkboxes. Do you do it in the top part of the subhandler.
By the way I always study and look at the examples I am givin. I often do other research on the net to always increase my understanding.

Thanks
Texas Pete

mrainey

Here's a list somebody provided way back - it might help you with some of the constant values.
Software For Metalworking
http://closetolerancesoftware.com

LarryMc

The controls in a dialog don't exists until you execute the domodal .
therefore you have to initialize any variables (incuding setstates) in "@IDINITDIALOG" as you suggested.

When you close the dialog you loose all the data (and settings) you entered while the dialog was open.
If you want to pass any values from the dialog back to your main program you'll have to store them in global variables before you close the dialog.

You can have the dialog return one int value (like a function) if you set it up correctly.  It's usually used just for dtermining if a dialog was 'canceled'.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

Quote from: mrainey on May 11, 2010, 05:35:33 AM
Here's a list somebody provided way back - it might help you with some of the constant values.
Here's the download link for what I use for declarations and constants.
I have found an error here and there but it has done me a lot more good than harm.

http://www.activevb.de/rubriken/apiviewer/downloads/apv2004_v310.exe

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

TexasPete

Thanks a lot Larry,
I have been collecting everything I can get my hands on. The hard part is finding the informations. Researching the information on the different browser just to come up with something that will work with most of them has been very time consuming. I have looked at thousands of pages by now. It is no wonder I get confused!

Thanks Texas Pete

LarryMc

TexasPete

I know Graham won't want to here it, but based upon all the code you sent me IMHO I would turn it into an EBasic project with multiple source files.

First thing I would do is put all those definitions at the beginning of the program in an include file so I didn't have to scroll through 100's of lines of code to find the real start of the program.

I would take the time to indent everything properly.
I would put one or more blank lines between the end of one sub and the start of the next sub.
With everything not indented properly(or not at all) and no spacing it sure makes the code hard to follow.

I'm only saying that because of all the code you said you have yet to add.
I think it is going to get really hard for you to follow and find bugs before you are through.

You are calling subroutines in CBasic with GOSUB mysub
In EBasic they would change to just mysub()

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

TexasPete

Larry , you are absolutely right . The program in the other language consists of about 10 or 12 include files. Once, I get the dialog working I have one more window to add . Trying to understand the differences between the languages made me feel very uncomfortable. I know that CB has the ability to have different include files that are precompiled. I came from an enviroment which allowed me to jump quickly from on include file to another always being able to look at my code an then compile. If I need to pre define a variable  I could just flip over and make the change. As I understand a pre compiled module did not give me that luxury. As I continued to translate I found that certain functions had to be rewritten and in some cases done away with entirely. Anyway, I will start organizing the code into different modules but I needed to understand how those module would work together. I have found about 20 different rules that had to be changeed to make the modules work together. With nice people giving me a hand if I get stuck , It really helps. Everything, is not fully explained in the manuel and sometimes people get confused about something.

Any way I will be organizin the code more and more putting it under different headings and stuff.
Without meaning to hurt anyones feelings. CB Debugger could be greatly improved and Its IDE.
Having an Ide that could simply use include files would have help me.
I know that those improvements were made on EB. Maybe GWS and some others could help make those improvements. I personally believe
the CB is a better interpreter than most out there and should have a much bigger following.

Thanks
Texas Pete

LarryMc

TP
I took your main source file and loaded it into EBasic so I could correct the indenting.

In doing so I found numerous places where there are if statements without endifs, returns outside of subs, if/endif statements spanning multiple case statements, etc.

The point being, not to be critical, but to suggest that you will save yourself an awful lot of debugging grief if you stop and take the time to clean up the code so those types of things are easily identified and corrected before they cause you problems.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library