|
Hi
I was wondering if some one could help me with the sort function of CList control. My first column consists of numbers to be added by the user. I need the numbers to be sorted but If I make the member variable integers I am unable to use the InsertItem function so am I restricted to CStrings?
|
|
|
|
|
Catherine... were you referring to sorting a CList or CListCtrl?
|
|
|
|
|
I have an Edit control where the user enters a number. When the user presses
return the number gets added to a CListCtrl. The edit control's member variable is a CString. I want the numbers in the ListCtrl to be sorted numerically, however by selecting ascending sort on the ListCtrl the nubers appear for example in this order:
1
2
22
3
4
|
|
|
|
|
it sounds like you might need to convert your CStrings to ints (using the atoi()) during your sort function, something similar to:
int n1 = atoi((const char*) pListCtrl->GetItemText(lParam1, 0));
int n2 = atoi((const char*) pListCtrl->GetItemText(lParam2, 0));
then doing the comparision on the ints.
|
|
|
|
|
Just wondering if any of you clever peeps out there
could help me in creating my first c++ dll.
I just need and example of a dll containing a function
that takes one int, multiplies it by two and returns
the answer.
The main bit i'm stuggling to find out is how you make
this function accessable so it can be called externally;
I managed to find out how to do it in delphi e.g.
library Sample;
uses
SysUtils,
Classes;
{$R *.RES}
function MultiplyByTwo(X: integer): integer; cdecl; export;
begin
MultiplyByTwo := X * 2;
end;
exports
MultiplyByTwo;
begin
end.
but as i don't have access to delphi, it's not much help.
Any help would be greatly appreciated.
|
|
|
|
|
Yeah, that delphi stuff is pretty well useless...
Have a look at the DLL sction of codeproject. It should help you out.
With time we live, with money we spend!
Joel Holdsworth
|
|
|
|
|
Thanks Joel,
What would be really useful was if you could, knock me up an example
that mirror's the functionality of the delphi example.
Just to explain why i need this, we use an automated testing tool
called QARun, it's good for it's job but the functions it can perform
are a bit limited. One thing you can do is use call functions in external
dll's.
Once i've got the basic's of how to structure and compile the dll i can usually
find the code for what i need to do in the msdn library or on the web.
It's partly a learning exercise for me, but it will also come in handy when
i need to to something that qarun can't do directly (just about anything do to
with the registry for example.)
If you could help it would be much appreciated.
Simon
|
|
|
|
|
Any body can give me a hint? I have two projects, one is dialog based, one is SDI based. I have draw up all the resources for the dialog based project, and I want to copy all of them to my SDI based project. Is there any easy way to do it?
Thank you very much in advance!
|
|
|
|
|
1. Open your target project.
2. Open the .RC from your source project.
3. Select the resource you want to copy.
4. Copy.
5. Select the target resource tree
6. Paste.
7. Repeat 3-6 until you're done
8. Save.
You might want to look at my article @ http://www.codeproject.com/useritems/no_rc.asp
With it you can save the resources as a shared file.
Brad
|
|
|
|
|
Thank you for the instruction and the nice article. I've got it done.
Thanks a lot!
|
|
|
|
|
I'm writing an opengl program in an MDI application using visual C++ version 6.0
When I work on the program at work and then take it home, it works fine. But when I work on it at home and then try to run it again at work, I get errors when I compile.
Here's some of the errors:
:\Windows\Desktop\Heart Program newest\TestGLView.cpp(227) : error C2065: 'glEnable' : undeclared identifier
C:\Windows\Desktop\Heart Program newest\TestGLView.cpp(229) : error C2065: 'glClearColor' : undeclared identifier
C:\Windows\Desktop\Heart Program newest\TestGLView.cpp(231) : error C2065: 'glClearDepth' : undeclared identifier
C:\Windows\Desktop\Heart Program newest\TestGLView.cpp(234) : error C2065: 'glLightfv' : undeclared identifier
C:\Windows\Desktop\Heart Program newest\TestGLView.cpp(271) : error C2065: 'glBegin' : undeclared identifier
In fact, every error I get is of this sort. That the OpenGL commands are undeclared identifiers. I checked if the headers files were included and they were. I also checked if the appropriate libraries were linked and they were. Its the exact same program, works fine at home but screws up at work after it has been run at home. Its also the exact same version of visual C++. Anybody know what the problem is and how I could fix it?
|
|
|
|
|
If you have the same VC++, and the same project, with the same files in it, the differece can be in Tools/Options/Directories may be is missing any include directory or lib directory. May be the project in the other machine have other header in another directory and you ignore that...
I saw that the problems are in de declaration of some variables.... (I put my money in that you forgot any header file)
Best Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Hi me again with one another question.
I am writing a program which opens a serial port in order to write on it . I succed in opening the serial port and configuring it . Somebody wrote a function for me but this function sends integer to serial.I want to send string to serial . The code is bellow :
int CMC35ProjectDlg::Send(BYTE data)
{
///////////
//Begin
//////////
//Send Data to serial Port
DWORD dwBytes=0;
BYTE d=data;
int ret=d;
BYTE* sbuf=&d;
BOOL stest=WriteFile(hcom,sbuf,1,&dwBytes,NULL);
if ((stest&&dwBytes)==FALSE)
{
MessageBox("Connection between your PC and MC35 device connot be establish.\nPlease try again later.\nCheck the serail cabel.\n(ËÜèïò êáôÜ ôçí åêôÝëåóç ôçò óõíÜñôçóçò send).",
"Error!",MB_OK | MB_ICONSTOP);
ret=-1;
}
return ret;
//////
//End
//////
}
Any idea converting this function to send strings to serial?
Another problem I have is that I want a variable to take the follow content AT+CMGL="REC UNREAD".How can I succed it?
Thank you in advence.
X-The truth is out there.
|
|
|
|
|
The easiest solution is to loop over all the characters of the string and call CMC35ProjectDlg::Send to send them all one by one. This is highly inefficient, though, a better approach is to use WriteFile to write all the chars in one call. CHeck your documentation for this function.
As for your second question, I guess it's the embedded quotes that's causing you trouble. The syntax is as follows:
const char* command="AT+CMGL=\"REC UNREAD\""; Good luck.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you for your help.My second question was answered and I thank you.This works just fine.But I don't understand your help for my first question.Look my code above I use the WriteFile function.How can I use this function in order to send strings to serial port.Any idea?
Thank you in advance.
X-The truth is out there.
|
|
|
|
|
Hello,
Can anyone tell me why one should use this feature of declaring classes inside other classes. Apart from not having the namespace too big at least.
Because apparently there's no feature involved. You cannot have access to the enclosing member classes, which is a cool thing in Java I reckon.
Best regards,
Alexandru Savescu
|
|
|
|
|
The namespace issue is IMHO the main reason for having nested classes. Consider for instance different containers (vector , list , map ) like the ones provided by STL. Each container features a different iterator type, which is best defined as a nested class, so that yu name it vector::iterator , list::iterator and so on. This uniformity makes it simpler to write generic code, also.
Another point (not related with this) is that having a nested class in the private section of an enclosing class makes the nested class inaccesible (and not derivable) to external users.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I used BCGMenuBar in an SDI application.
I changed the layout of MenuBar by using
m_wndMenuBar.ModifyStyleEx(0,WS_EX_LAYOUTRTL);
where m_wndMenuBar is a pointer to CBCGMenuBar.
PROBLEM
........
The "POP UP MENU" when i have a click on menu bar, does not consider the Right to Left layout.
It pop up in the normal(left to right style).
How i change the style of pop up menu....
I mean how i open it in the (Right to Left)fashion.
|
|
|
|
|
You should post this question to the bcg forums on www.bcgsoft.com
Best regards,
Alexandru Savescu
|
|
|
|
|
hi every body
i had an old projects desgined with vc++5.0 (source code), when i built these projects I couldn't make an exe file for this project.
Best Regards
|
|
|
|
|
Any error messages, warnings etc???? What's in the output window?
|
|
|
|
|
Perhaps you could give more details about the errors... for example what does the compiler say? Linker error?
-Dominik
|
|
|
|
|
the problem happen when I press Go Button the program, i got the following message:
Unhandled exception in file.exe: 0xC0000005: Access Violation
Best Regards
|
|
|
|
|
This probably has to do with initialization. You are most likely referring to an object that has not yet been initialized. Try to step through your code instead of using GO and determine which statement results in the error.
Good luck
|
|
|
|
|
The error code as follow:
First-chance exception in 日记.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
How can I solute it?
Don't look at me in that way!
|
|
|
|