|
I want to sort a change the sorting of a listbox.I tryed it as "virtual int CompareItem....." and as "afx_msg int CompareItem...." but these functions are never called and the list is sorted normally. What is the problem?
(except my english)
|
|
|
|
|
MSDN:
Called by the framework to determine the relative position of a new item in a sorted owner-draw list box. By default, this member function does nothing. If you create an owner-draw list box with the LBS_SORT style, you must override this member function to assist the framework in sorting new items added to the list box.
Short:
Have u set LBS_SORT style for the listbox??
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Only owner-draw listboxes use this message. If you have plain listbox and want to use non-standard sorting, then you'll have to sort yourself before adding items.
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
Listbox is owner-draw fixed and LBS_SORT is set. Other functions (DrawItem, MeasureItem) are working well. Sorting work, but only standard not my way
|
|
|
|
|
I guess you have LBS_HASSTRINGS style set. With this bit enabled, you won't get WM_COMPAREITEM, because listbox assumes that sorting means string sorting.
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
Listbox is owner-draw fixed and LBS_SORT is set. Other functions (DrawItem, MeasureItem) are working well. Sorting work, but only standard not my way
|
|
|
|
|
Does anyone know of a way to get the dialog units for the text in a CStatic control? I'm trying to dynamically resize some controls and what MSDN says to do seems to always return 25-50% too big.
Here is what I am trying:
CDC *pDC;
CSize cStringSize;
pDC = m_MyStaticControl.GetWindowDC();
cStringSize = pDC->GetTextExtent ("Some string I want the size of...");
I've also tried DrawText(...) but that returns the same size.
Thanks for the help,
David
|
|
|
|
|
You need to select the right font into DC first. Default font is larger than the one used by your control.
As a little OT note, you should also use CWindowDC or CClientDC instead of GetWindowDC call.
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
Tomasz,
Great! Thanks for the help, that did the trick. One more question, how do I figure out what font the CStatic is going to use? I ended creating a different font first (looks better anyway).
Thanks again,
David
|
|
|
|
|
|
Simple, thanks yet again.
|
|
|
|
|
I need to manipulate an array so that the first row is the last second row is next to last and so on with a 2d array.
do I need to make a tempArray or can it be done without creating another array? S ome code to help get started too would be helpful.
|
|
|
|
|
If you want to read the array in reverse order use code similar to this:
for (int i = MAX - 1; i > -1; i--)
{
for (int j = 0; j < MAX; j++)
{
}
}
That way, the last row will be read first.
_____________________
"So in the interests of survival, they trained themselves to be agreeing machines instead of thinking machines. All their minds had to do was to discover what other people were thinking, and then they thought that, too."
Breakfast of Champions, Kurt Vonnegut
|
|
|
|
|
what i need to do is not only read it backwards but change the array so that it is too.
|
|
|
|
|
If I have something like IDS_STRING1's Caption "Example"
and define _UNICODE. Then do csString.LoadString(IDS_STRING1),
is csString a unicode string? (so dont' have to do _T)
|
|
|
|
|
CString::LoadString calls ::LoadString internally - you'll get Unicode string in Unicode build of your app.
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
As Tomasz says, the CString you get back will be appropriate for your compile time setting.
Strings in the string table are ALWAYS UNICODE, but if you use ::LoadStringA to retrieve them, they come back as ANSI/MBCS, while ::LoadStringW doesn't do the conversion.
We use ::LoadString, which is mapped to one or the other, so it doesn't matter.
You don't need to use _T on a CString that is set using LoadString anyway, you only need that on string (or character) literals so that the compiler can make them wide when it needs to.
Steve S
[This signature space available for rent]
|
|
|
|
|
char* a = new char [100+1];
a =0;
cFile.Read(a,100);
a[100] = 0;
AfxMessageBox(a);
cFile.Close();
}
catch(CFileException e)
{AfxMessageBox("prob");}
} I'm trying to see what could make CFile:Read throw an exception. I tried the folowing but got a debug assert when I expected it to go into the catch...I cant imagine what else could make Read throw an execption..
Thanks,
ns
|
|
|
|
|
Step into cFile.Read(a, 100); line. Put the breakpoint there, and when it's hit, press F11.
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
SO why does Read have a throw Exception statement next to it in MSDN? I was taking that to mean that its a function that will throw an exception as opposed to Open which doesnt....so I am trying to see what all can make it throw an exception...
(Appreciate the F11 idea. Oh - its step into..makes sense> So far I havent ever stepped into any MFC functions, just my own functions....)
Thanks,
ns
|
|
|
|
|
|
in which way ur considering using it?
Item monikers , File monikers , Anti-monikers
Pointer monikers or as a Generic composite monikers ?
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Does anyone know how many threads can be active under Windows 2000. I'm writing an ISAPI that could create a lot of threads ( 50-100-150 ). The thread's routines are very minimal and no complex calculations are being performed. Is there a cap on the number that can be created and/or will a 100 threads comprimise the stability of the server.
|
|
|
|
|
It all depends on the state of these threads. If they're mostly suspended/sleeping/waiting there will be no performance hit. If you plan to have 100 *executing* threads, you better use thread pool.
Right now there are > 300 threads on my XP box. I'm only browsing the internet and downloading mp3s.
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
How many processors and memory have you got? While there is theoretically no limit there is a practical limit depending on the hardware.
But maybe you should consider using jobs with a thread pool?
...make it about Visual C++, and don't ever mention Visual Basic. Nick Hodapp (MSFT) in Semicolon[^]
|
|
|
|