|
Use strcmp to compare to strings.
int StrCmp(
LPCTSTR lpStr1,
LPCTSTR lpStr2
);
Parameters
- lpStr1
- [in] Pointer to the first null-terminated string to be compared.
- lpStr2
- [in] Pointer to the second null-terminated string to be compared.
Return Values
Returns zero if the strings are identical. Returns a positive value if the string pointed to by lpStr1 is greater than that pointed to by lpStr2. Returns a negative value if the string pointed to by lpStr1 is less than that pointed to by lpStr2.
Remarks
This function returns the difference in value of the first unequal characters it encounters, or zero if they are all equal. For example, if lpStr1="abczb" and lpStr2 = "abcdefg", StrCmp determines that "abczb" is greater than "abcdefg" and returns z - d.
This is how you would determine if one string should go before or after another string, then you could write your own sorting algorithm, or you could use the sort function in STL.
|
|
|
|
|
Do some homework on Quick sort which i think is the fastest, but BubbleSort i believe is the easiest to implement.
Are you working with C arrays or MFC/similar string class?
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
The best way is to use real (i.e. STL ) containers. If you use vector, you have an array, which can be indexed in the normal way, but you can also call std::sort, and that's just the beginning.
christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
hi all
can anybody tell me how do you insert some objects of some type in some array in (alphabetical order)?
or is there anyway you can make your objects comparable like in JAVA??
THANKS FOR ANSWERING MY QUESTION
|
|
|
|
|
Are you using STL, or a plain array data type.
You are on your own if you are simply creating an array of some sort of object.
However if you are using the STL set or map class, the items will be inserted in order. Then again if you use the vector, after you insert all of the items you could use the sort function to sort the items.
If you are more specific with your problem, I may be able to suggest a better solution.
|
|
|
|
|
ok here is what i want to do:
let's say i have an Object of type Stock(nameOFStock, initialValue,....)
lets's say i want to add all my Stock objects to some array called stocks
but i want to add them in alphabetical order.
you know what i mean now?
thanks for your time.
|
|
|
|
|
How are you going to access the array? If you want to perform a lookup based on the name of teh stock, I would simply use the STL map. You can add items and it will automatically sort the items. So if you use an iterator to view all of the objects in your map, they will be sorted.
Also you can create a map like this:
<br />
map<char*, CStock*> mapStock;<br />
then you can add items like this:
<br />
mapStock["msft"] = new CStock(...); <br />
and you can later access the object like this:
<br />
CStock *stock = mapStock["msft"];<br />
It is a pretty easy container to use, it sounds like it would be a good fit for your case.
|
|
|
|
|
Hi all,
Does anyone knows where can I find a sample program which will perform course enrolment functions ? Thanks.
Anna D.
|
|
|
|
|
That sounds like a DNA with web services.
Try WROX DNA at amazon.com search.
I dunno about your program.
Be more specific,heh¿
Antoine
Coming home from Vancouver. I look like a hobo! lol
|
|
|
|
|
hi Antoine,
sorry for not beening specific enough with my problem, I am looking for a program that allows an user to enrol a course by entering a user ID under DOS prompt. Would you know any similar program to this on the net? thank you for your help.
Anna D.
|
|
|
|
|
There is no generic way to do that, I figure?
What software do you use to handle courses, and who made it? I suggest asking the developers/software company for help if you didn't write the system yourself, nor have the source at hand.
/moliate
|
|
|
|
|
I've got a file browsing list control inside a custom Outlook Control. The problem is that when I remove all the items in the list control and fill them with a new list (as in the user selects a different folder to browse), a bunch of blank space gets left at the top. Below is a screenshot:
(dunno why this image doesn't want to display)
This seems about the same amount of space as the scroll offset before the list items were updated. I've tried a calling a bunch of functions to see if I can get rid of this, but can't. (The attemps are shown below under the //!!! part.
void
cPkpPhotoListControl::OnRightClick(NMHDR* pNMHDR, LRESULT* pResult)
{
cResId PopupMenuResId = GetPopupMenuResId();
//!!!
CListCtrl::SetWorkAreas(0, NULL);
CListCtrl::Arrange(LVA_ALIGNTOP | LVA_ALIGNLEFT);
CListCtrl::SetWorkAreas(0, NULL);
SetScrollPos(SB_VERT, 0);
if(!PopupMenuResId.IsVoid())
{
cPoint ScreenPoint;
GetCursorPos(&ScreenPoint);
//!!!!
cPoint sss = ScreenPoint;
ScreenToClient(&sss);
cWindowHelper Helper(this);
Helper.HandlePopupMenu(PopupMenuResId, ScreenPoint);
}
*pResult = 0;
}
Now I've hooked this into the right mouse click handler so I they are called whenever I hit the right mouse button (just for debugging).
I've also tried clicking the top of this space, and that point comes out as near 0 in client coordinates, so I know that white space is part of the list control. I can also drag a selection box in this white space.
Anyone have any ideas? Any other commands I can try?
Cheers,
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
I cannot get CDragListBox to work and cannot find an example that uses it. Here is my current code:
class CTheView : public CWindowImpl<CTheView, CDragListBox>
{
public:
DECLARE_WND_SUPERCLASS(NULL, CDragListBox::GetWndClassName())
};
class CMainFrame : , public CDragListNotifyImpl<CMainFrame>
{
CTheView m_view;
LRESULT OnCreate(UINT , WPARAM , LPARAM , BOOL& )
{
m_view.MakeDragList();
}
BOOL OnBeginDrag(int , HWND , POINT )
{
ATLTRACE("CMainFrame::OnBeginDrag\n");
return TRUE;
}
}; Any help is appreciated.
|
|
|
|
|
I am creating an application and I want to make a new window pop-up when I select an item from the menu. I need this to be a different window from the main window and have been trying for weeks to get it to work. Somebody please help me...
Marjorie
|
|
|
|
|
I think you mean you have multiple document application and you want different child framework.If I am right reply this message(If I am not right display your problem better) I know the solution and I'll give you the key;)
Mazy
You can find a solution (even a foolish one) for all problems (even big ones)
|
|
|
|
|
Mazy,
I think that's what I want. I'm new to MFC and am not too sure about the terminology.
Marjorie
Marjorie
|
|
|
|
|
Now It's 2:30A.m here and I'm really tired ,I'll send it to you tommarrow
I try to explain it completly
Mazy
You can find a solution (even a foolish one) for all problems (even big ones)
|
|
|
|
|
Oh,Before I go and sleep I found good example for you.You can find exactly what you want here:
http://www.njnet.edu.cn/info/ebook/c++/vc524h/ch23/ch23.htm
Mazy
You can find a solution (even a foolish one) for all problems (even big ones)
|
|
|
|
|
Thank you
Marjorie
|
|
|
|
|
MDI-Multiple Document Interface
Paint Sho pro
Visual C++
SDI-Single Document Interface
Internet explorer
Notepad
Paint
I don't think this terminology is MFC specific, i'd think it would be more like WOSA(Windows operating system architecture).
cheers
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
I run a program with flex grid on my machine and it works great.
I run it on another machine and it tanks. I added the file
msflxgrd.ocx to c:\windows\system and then the program works
on the other computer.
I am alittle worried because this is the first time I have used
activeX in my program. Is there anything else I need to do
to make flex grid work on different machines or putting that
file in that directory is it? I am just worried.
Please, please, any response, any one can give me will
be greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
You have to register the ActiveX on the computer you want to use it.
do this:
on the start menu run the command line and run this:
regsvr32 xxx\xxx\xx.ocx --->path of your ocx
Mazy
You can find a solution (even a foolish one) for all problems (even big ones)
|
|
|
|
|
You can also use installshield and then distribute your project;)
Mazy
You can find a solution (even a foolish one) for all problems (even big ones)
|
|
|
|
|
Hi Guys,
i am using the following code to calculate the Calendar Week, using Month Calendar Control (m_cal1).
in the heade file...
COleDateTime ActualWeek1;
COleDateTimeSpan Weekdiff1;
in the function OnSelchangeMonthcalendar1....
SYSTEMTIME sysTime;
m_cal1.GetCurSel(&sysTime);
ActualWeek1.SetDate(sysTime.wYear, sysTime.wMonth, sysTime.wDay);
COleDateTime ActualTempWeek1( sysTime.wYear, sysTime.wMonth, 0, 0, 0, 0 );
Weekdiff1 = ActualWeek1 - ActualTempWeek1;
week1 = Weekdiff1.GetDays()/7+1;
CString week;
week.Format("%d",week1);
AfxmessageBox(week);
If i use this code in my function OnSelchangeMonthcalendar1 and select a date, it always starts the week from wednesday and according to this it displays the wrong week.
So how can i get the correct calendar week ??
Best Regards
Sonu
|
|
|
|
|
COleDateTime curDate = COleDateTime::GetCurrentTime();
int weekDay = curDate.GetDayOfWeek();
|
|
|
|