|
In general there are four possible rectangles to consider, the upper one, the lower one, the left one and the right one. If the coordinates of the outer rectangle are (ol, ot)-(or, ob) (“o” for outer and “l”, “t”, r” & “b” for left, top, right and bottom, respectively) and the coordinated of the inner rectangle are (il, it)-(ir, ib) are the coordinates on the inner rectangle (“i” for inner) the four largest rectangles that fit in the remaining space are:
Top:
(ol, ot)-(or, it)
Bottom:
(ol, ib)-(or, ob)
Left:
(ol, ot)-(il, ob)
Right:
(ir, ot)-(or, ob)
All that remains is to calculate their areas and choose the biggest one.
[ADDED]
I just noticed you want many inner rectanges and not just one. This makes it harder. Obviously my method assumes just one.
Steve
|
|
|
|
|
I took basically the same approach, except that I only calculated the space to the left and right of the inner rectangle. It serves the window at hand which has the appearance of a tool bar with buttons to the left and right and a large space in the center. But I ran into a few problems while trying to calculate vertiacal space at the same time as horizontal space. Though through your explanation I can see how it can be achieved.
Due to the nature of the program, I think it best to leave this particular method as virtual. Thanks for your input.
|
|
|
|
|
Excellent. Thank you. I was having trouble finding that wizard, I had only seen it via the context menu on the dialog, and that for some reason did not have all the base classes.
|
|
|
|
|
Quite a few of the articles on this site instruct to do something similar to the following with VS7:
Derive a new CListCtrl based class (here CMyListCtrl). In the VC IDE, this is as simple as selcting 'Add Class...' from the MFC Class wizard then, in the new class dialog, naming the control and selecting CListCtrl as the base class in the drop down list.
However I am using VS2005(VC++8) and the only base classes listed in the wizard are CDialog, CDHtmlDialog, CFormView, COlePropertyPage, and CPropertyPage. I ran into this problem with a CTabCtrl article also. The code compiles fine from the article though, I suppose i'm missing something simple.
Thanks!
|
|
|
|
|
Have you created the application as a standard MFC application?
File->New->Project select MFC in left pane, select MFC app. in right pane. Type solution name and OK.
Click finish to accept standard MFC settings for this test.
Select the "class" tab in the solution explorer, and right click the application name at the top. Select Add->Class from the drop down list. Ensure MFC is selected in both panes and click Add. Click the pull down arrow on the Base Class: combo box, and you should have all the classes available. If not there is something wrong with you installation.
Hope that is what youare trying to find out.
|
|
|
|
|
Hello
Does anyone know how i can use "FOR XML" expilicit command with ODBC in Visual C++ 6.0?
thx
-- modified at 20:39 Saturday 4th November, 2006
|
|
|
|
|
I'm asking this question because i tried many times to find a way to change connection parameters such as times out , number of retries , login , password every thing when the user intend to do so when i found a function called RASdialup() and other functions and by filling the RASDIALPARAMS sructure and after the excution of prog finally and unfortunatly i found RAS dial up not useful since the adsl modem has been used, after i decided to look back to WININET library .. another problem found is we can only change the 'PROXY' authentication :
//hOpen is the HINTERNET handle created by Internet Open
//strUsername is a string buffer that contains the proxy username
InternetSetOption(hOpen, INTERNET_OPTION_PROXY_USERNAME,
strUsername, strlen(strUsername)+1);
//strPassword is the buffer that contains the proxy password
InternetSetOption(hOpen, INTERNET_OPTION_PROXY_PASSWORD,
strPassword, strlen(strPassword)+1);
the second flag|parameter INTERNET_OPTION_PROXY_USERNAME can be changed only to INTERNET_OPTION_USERNAME but WITH condition calling InternetConnect function and return a handle hConnect, (for my point of view i want the first flag to be NULL to indicate that we can change the DEFAULT SETTINGS).
Note that there is a way to use INTERNET_OPTION_PER_CONNECTION_OPTION as a customized option the default settings changed well and we can use LAN connection options but without authentications change!! :
BOOL SetConnectionOptions()
{
INTERNET_PER_CONN_OPTION_LIST list;
BOOL bReturn;
DWORD dwBufSize = sizeof(list);
// fill out list struct
list.dwSize = sizeof(list);
// NULL == LAN, otherwise connectoid name
list.pszConnection = NULL;
// set three options
list.dwOptionCount = 3;
list.pOptions = new INTERNET_PER_CONN_OPTION[3];
// make sure the memory was allocated
if(NULL == list.pOptions)
{
//return FALSE if the memory wasn't allocated
return FALSE;
}
// set flags
list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
list.pOptions[0].Value.dwValue = PROXY_TYPE_DIRECT | PROXY_TYPE_PROXY;
// set proxy name
list.pOptions[1].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
list.pOptions[1].Value.pszValue = "http://proxy:80";
// set proxy override
list.pOptions[2].dwOption = INTERNET_PER_CONN_PROXY_BYPASS;
list.pOptions[2].Value.pszValue = "local";
// set the options on the connection
bReturn = InternetSetOption(NULL,
INTERNET_OPTION_PER_CONNECTION_OPTION, &list, dwBufSize);
//free the allocated memory
delete [] list.pOptions;
return bReturn;
}
If still not understand ignore it and help for how to change all default connection settings with any type of connection (LAN/ADSL/PHONE DIAL UP) ... I am really stuck
Anyone who considers arithmetical methods of producing random numbers is, of course, in a state of sin.
John von Neumann
|
|
|
|
|
I've seen some application that customise buttons on the title bar of a window. There are tutorials on CodeProject about this. My question is, although I can customise a button on my own application title bar, is there a way I can do this globally for all windows? I want to write an extension to add a button/function to every window/application.
Can anyone point me in the right direction of where to begin and any decent reference material?
http://www.asura.co.uk
|
|
|
|
|
The buttons on a title bar are not actually buttons, they are just regions in which you can click. To install a global button you would have to globaly hook the WM_NCPAINT then calculate the position for each window. I can't imagine it being too difficult, but you would have to take into account the window style for each window.
|
|
|
|
|
Thanks for the info.
I assume my application needs to be a 'shell extension' COM object as I want my application to be integrate into all visible windows/applications without manually running anything. I'm new to that area of programming and from what I gather there is very little documentation (either that or I'm not using the right search keywords )
... can anyone offer any advice?
http://www.asura.co.uk
|
|
|
|
|
http://img115.imageshack.us/img115/2114/erroruq1.jpg[^] what is wrong with my aplication? when it runs on my pc everything is alright but when i try to run it on others PC's it gives an error like that above.
I am running on Windows XP SP2 while others i think on Windows XP no SP or SP1... but there is no difference between sp1 and sp2 at least for applications running, i think...
any ideas how to fix that? maybe compilator settings are wrong?
thank you in advance for help
|
|
|
|
|
Are you using manifest files? I had a similar problem some time ago when using them.
This[^] may be of some help to you.
|
|
|
|
|
|
if found that i need to install somewhat dll package to another PC... but thats useless at least in my case. I need standalone executable like Skype.exe and it doesn't matter how big it would be...
i didn't found anything useful about how to make standalone application. I have linked ATL libraries staticaly but thats not enought...
so how to make my application standalone?
|
|
|
|
|
you didn't answer my question. If you are using a manifest file, then you are forced to include the correct version of the dll's with your app. Try disabling the manifest.
|
|
|
|
|
ohh.. sorry if i disable the manifest then my application doesn't find MSVCR80D.dll
|
|
|
|
|
edvintas wrote: ...MSVCR80D.dll
There's the problem.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
edvintas wrote: I need standalone executable like Skype.exe and it doesn't matter how big it would be...
You'll need to staticly link to the CRT, to avoid having to redistribute the CRT DLLs with your app.
|
|
|
|
|
wow, it works
it is alive! :->
thanks... for advice
|
|
|
|
|
How can I get the keys of HKEY_CURRENT_USER? Are there any APIs?
Thank you?
modified 8-Mar-17 3:51am.
|
|
|
|
|
can you be a little more specific? You want to get a list of all the keys under HKEY_CURRENT_USER? Use the RegEnumKeyEx() in a loop increasing the dwIndex value each time. But make sure you do not make any changes to the registry within your loop. If you want to change any values, either store the key and do it after your loop, or break out then start looping again from the beginning.
|
|
|
|
|
|
I'm trying to implement a child window anchoring system into my window. My code works all well and good right up until the child window is resized to a point where it becomes invisible. This is the basic code I am using to calculate the new positions
::GetWindowRect(m_hWnd,&rcNew);
::OffsetRect(&rcNew,-rcNew.left,-rcNew.top);
::CopyRect(&rcOld,&m_rcWindow);
::OffsetRect(&rcOld,-rcOld.left,-rcOld.top);
int Xoffset = rcNew.right - rcOld.right;
int Yoffset = rcNew.bottom - rcOld.bottom; The value of rcNew is later stored.
Now heres the problem. For all child controls of the main window, it works. The new rectangle may contain negative figures which is no problem since it corrects itself when the window is again resized. But for the children of children an incorrect value is being assigned to the Xoffset and Yoffset values. I have traced this to the GetWindowRect() call. If a window is told to resize to a negative figure, it actually resizes to 0. Therefore GetWindowRect() returns a 0 width or 0 height. To do this correctly I need to somehow find the window rect as if it were inverted, ie a begative figure for the width or height. Any suggestions?
|
|
|
|
|
Not sure exactly how you're implementing your anchoring, but GetWindowRect get's the coordinates in screen coordinates, but the moving/sizing functions (MoveWindow, SetWindowPos, etc) work in client coordinates.
You can use ClientToScreen and ScreenToClient functions to translate between the two. If you move a parent window, the children will move also, since they're relative to the parent, so you shouldn't need to move the children of the children (but you will need to resize them).
This code will leave the child control at it's current x, y position, but adjust the child width based on the parent width:
::GetClientRect(m_hParentWnd, &rcParent);
::GetClientRect(m_hChildWnd, &rcChild);<br />
<br />
rcChild.right = rcParent.right - ( rcParent.right - rcChild.right );<br />
<br />
::MoveWindow( m_hChildWnd, rcChild.left, rcChild.top, rcChild.right - rcChild.left, rcChild.bottom - rcChild.top, TRUE );<br />
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Thanks for the reply but the code sample I gave is correct for what I am trying to do. I am specificaly using GetWindowRect() do to the extent of which I have customised the windows. GetClientRect() will no longer give a true reading. Also from my code you should see that I simply calculate the Xoffset and Yoffset then add or subtract this to the childs stored rectangle.
Since I posted the question I have managed to solve it. The first call to my function always comes from the main window, So I can pass in a NULL LPRECT forcing the function to call the GetWindowRect() api. Since this then calculates the new childrens position I can recurse the function passing in the newly calculated childs rectangle. This gives the added advantage of only needing to call the function once from the main window.
|
|
|
|