|
Simply call the API version ::GetWindowRect(), where the first parameter is the handle to the window from which to detect the coordinates. A second approach could be Attaching the handle to a CWnd object and then calling it's GetWindowRect (but I prefer the former way )
|
|
|
|
|
GGRRRREEEAAAAATTTT it's works fine !! i found
CWnd* pMDIClientWnd = CWnd::FromHandle(pFrame->m_hWndMDIClient);
if (pMDIClientWnd)
{
pMDIClientWnd->GetWindowRect(&ClientRect);
}
to Use m_hWndMDIClient, it is the right solution !! i get the coordinates of client area and i can to position my window where i want !!
THX THX again Schlaubi you help me so much, i should send you bottle of wine
|
|
|
|
|
jeremysay wrote:
i should send you bottle of wine
Nice idea ... thx
btw: I prefer the red one, dry and fruity
|
|
|
|
|
jeremysay wrote:
GGRRRREEEAAAAATTTT it's works fine !! i found
...and calling
::GetWindowRect(m_hWndMDIClient, &ClientRect)
would do it without needing to deal with CWnd.
Sorry, but in my last post I forgot the code snippets .. but luckily you found the solution anyway.
|
|
|
|
|
Schlaubi wrote:
but luckily you found the solution anyway
you tell me in post to see m_hWndMDIClient and i search sample code in google and i found an example, i didn't find this alone
|
|
|
|
|
I dont see a setItemIndex() in CListCtrl members but lets say I want to make my item #5, now the item #2 (and the original item #2 can just get pushed down in the list). How does one do that? I see Inserttem but thats not what I'm doing. Item #5 already exists in the list....
Appreciate your help,
ns
|
|
|
|
|
Use GetItem(5) to retrieve the item information, then delete it and add it again by using InsertItem().
|
|
|
|
|
Some days ago I got this very helpful hint here in the boards:
"In VC++ 7.0, there's an option called delayed loading which loads DLLs the first time thery're used. If you have this compiler, this is surely the fastest way to get your problem solved."
Could anybody direct me to this option in VC++ 7? I just instaleld it.
Thanks so much!
-- narada
|
|
|
|
|
Project Settings->Configuration properties->Linker->Advanced->Delay Loaded DLLs
|
|
|
|
|
Thanks a lot!
It's so great to get this help!
-- narada
|
|
|
|
|
... or xml config file
When declaring things like a MAX_FIELD_SIZE or MAX_(insert your thing here), do you use #define (which has no idea how the literal is being used in your code because it's a pre-processor directive [i think]) or do you use enums? Or do you keep all that stuff in the registry, or a config file?
Any thoughts/preferences/opinions?
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Well, I try to use const.
#define anyways is not a good idea. Since, there is no type-checking.
XML config file also sounds like a good idea.
I hate messing with the registry
Pankaj
Without struggle, there is no progress
|
|
|
|
|
pankajdaga wrote:
I hate messing with the registry
Same here!
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Nitron wrote:
#define or enum??
Are really two different things:
enums are for giving those nasty number mnemonic (right word? I just can't remember;) ) names, so your functions do not return 0, 1 and 2, but OK, NOT_FOUND and INVALID (or something).
A define is replaced by a const int (double, whatever), which typesafe and can be made class-local (if no one uses it outside of your class).
But I must admit that a simple #define is MUCH shorter...
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Is it not allowed to declare and define a varible in a .h file or what?
I moved over a couple of files from a .cpp file to a .h file and some of them was declared and defined. that caused the compiler to say "Bla bla already defined in FileName.obj". Is that because I did a defination of the varible in the .h file?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
I think doing a fresh rebuild might help. Clean up your project and build again.
Pankaj
Without struggle, there is no progress
|
|
|
|
|
define the variable in the .h, and initialize it in the constructor of the class. (could be the .h if you don't have a seperate implementation file, else put it in the .cpp @ in the constructor if you do. As far as "Global Variables", don't do it. It makes for very dependant code and doesn't allow for a modular design. Also, they make a large project relatively easy to screw up. If you need to access the member from somewhere else, make the member public.
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
>Is it not allowed to declare and define a varible in a .h file or what?
In short, no.
If you replace the #include "Foo.h" line in each cpp file with the contents of the header, then
the problem becomes more obvious. You have two "externed" variables with the same name, and the
linker objects (rightly!).
So you can have the declaration of the variable in a header, but the "implementation" can only
be in one OBJ (therefore only one C / C++ file.)
Global variables are almost always BAD anyway. (I know there are useful examples, but they are
the exception).
I hope that is a little more clear,
Iain.
|
|
|
|
|
Declare your global variables in your cpp files then using extern keyword in with variable definition in your header file. e.g.:
in your cpp file (foo.cpp):
<br />
int i;
in your header file (foo.h):
<br />
extern int i;<br />
now include your header file when needed in any cpp files with no compiler error!.
A. Riazi
|
|
|
|
|
Rickard Andersson wrote:
Is it not allowed to declare and define a varible in a .h file or what?
Sure it is. It is however not allowed to define anything twice, hence the name ODR - "the One Definition Rule".
I moved over a couple of files from a .cpp file to a .h file and some of them was declared and defined. that caused the compiler to say "Bla bla already defined in FileName.obj".
Well, there you go, having already violated the ODR.
Is that because I did a defination of the varible in the .h file?
Not exactly. You got that error because you defined (whatever you defined) from two different translation units. What you did was begging for trouble, and you got it in droves - apparently much more than you could handle.
Fix the problems by moving the definitions into the .cpp files they logically belong to and you're one experience and a compiling project richer.
|
|
|
|
|
hi there,
if got an server application, each connection(client thread) must be able to get data in and out of the database. Because of the multible connections the database must be contacted by only 1 class(because of locked up records and that stuff). What is the best way to do something like that?
My own solution would have been to make a message list(/waiting list) for the database-class(like windows does) and make the database-class a thread that keeps checking the messages and respond to them. That way the class handles each oparation after eachother and gives the feedback toward the thread. This would mean that i have to make a linked list of a structure that contains something like this:
<br />
- Owner of the message(thread ID)<br />
- Command for the database(something like SQL or maybe a selfmade kind)<br />
- Pointer to the Recordset where the thread retrieves all information from the database<br />
My problem is not to realize something like this, my problem comes wenn i have to make an Recordset that is variable and only contains information. CRecordset only makes a Recordset that is connected to an database, and thats not what i need. Does anyone know how to do this?
I hope you'll understand what i mean, my english is not the best.
[]D [] []D [] (from holland)
|
|
|
|
|
MSDN says:
static int CALLBACK
MyCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
CListCtrl* pListCtrl = (CListCtrl*) lParamSort;
CString strItem1 = pListCtrl->GetItemText(lParam1, 0);
CString strItem2 = pListCtrl->GetItemText(lParam2, 0);
return strcmp(strItem2, strItem1);
}
void snip_CListCtrl_SortItems()
{
extern CListCtrl* pmyListCtrl;
pmyListCtrl->SortItems(<code>MyCompareProc</code>, (LPARAM) pmyListCtrl);
}
In the above,
pmyListCtrl->SortItems(<code>MyCompareProc</code>, (LPARAM) pmyListCtrl);
there are no arguments passed to MyCompareProc> So what is it comparing? I am puzzled. I thought somehow I would need to send in the list of items in that column to the comapre function? Thats what lPAram1 and lPAram2 are right? How is it automatically stepping along my column and comapring stuff? I dont see this in the code....
Appreciate your help,
ns
|
|
|
|
|
|
That is what list control does internally, it calls supplied function to sort the items.
|
|
|
|
|
Okay. I didnt realize that theres magic going on I cant see.....like the listctrl getting cleared and repopulated with the new sorted items etc. Nor did I see the items going in by pairs......it just knew that it was responsible for sending in the items in that clicked column and doing the compare as long as I give it the CompareFunction body....hmmmm.
Thank you.
Appreciate your help,
ns
|
|
|
|