|
LV_ITEM lvi;
lvi.mask = LVIF_PARAM | LVIF_TEXT | LVIF_IMAGE;
lvi.iItem = 0;//0:add head, listCtrl.GetItemCount():addTial
lvi.iSubItem = 0;
lvi.pszText = text
lvi.iImage = 0;
listCtrl.InsertItem(&lvi);
|
|
|
|
|
If I understand what you are asking you want the list items to appear at the bottom of your list like this with one item:
---------
| |
| |
| |
| |
| |
|Item 1 |
---------
And like this with 2 items:
---------
| |
| |
| |
| |
|Item 2 |
|Item 1 |
---------
If this is correct, then I beleive that you will either need to subclass the edit control and control how the items are painted into the control. This will be more than just an ownerdrawn listbox, because you will also have to change the location of the list item.
I have never tried this in the listbox, and I do not know if it is possible to change the location of a list item. In this case you would have to create an completely new control that managed all of the list elements itself.
|
|
|
|
|
error C2084: function 'void __thiscall Stock::setNumOfOutShares(int &)' already has a body
thank you !
|
|
|
|
|
If you have implemented the function in a file header, you will need to add 'inline' to the beginning of you function declaration, otherwise move the function implementation to a .cpp file.
|
|
|
|
|
can you please tell me how do i write a regular class
?
i did not have this problem be4 but when i put the class definitions(those were my .cpp files), i added them to my class declarations (.H files)
i got hundreds of errors C2084??
can you tell please tell me what is the right way to write classes?
and what do you mean by add 'inline'to the beginnig to the function?
can you give an example?
thank you so much
|
|
|
|
|
There are a number of ways to write a class. I think that how you do it depends on the current situation. Alot of times programming style simply depends on your tastes. I have developed code with alot of other people, and they all like to organize their classes in their own ways. One thing to keep in mind though, is that alot of people may see your header files if they are going to use your classes, the implementation files are rarely ever seen. With this in mind, the code that you do not want other people to see should be placed in the .cpp file.
If you have a large class with complicated implmentations I would create a header file with the class and function declarations, then place the implementations in the .cpp file.
If you class has a lot of simple get and set functions, these are good candidates for inline functions.
For instance:
<br />
class Stock<br />
{<br />
<br />
CHAR* GetName ()<br />
{<br />
return name;<br />
}<br />
<br />
};<br />
or like I suggested earlier, add the inline declaration to the function implementation.
<br />
class Stock<br />
{<br />
<br />
CHAR* GetName ();<br />
<br />
};<br />
<br />
inline CHAR* Stock::GetName ()<br />
{<br />
return name;<br />
}<br />
<br />
inline functions will make the entire piece of code that is created for the function will be compiled inline where the function would normally be called instead of actually calling the function. The only drawbacks to inline functions is that if you do it too often, the size of your program will become bloated. Use function inlining judiciously.
The reason why you get a million errors with out the inline declaration, is because every file that includes your header file recompiles the functions that should be declared inline, and when the linker tries to link all of these files it finds multiple implementations for the function. Using inline forces only one implementation.
|
|
|
|
|
here is what i want to do!
I have written all a whole bunch of classes (.h and .cpp)
using visual C++.
now i want to create a project that contains all those classes,
then i want to compile it and link it without running it(to create project.exe)
can any one give me a hint how u do that?
how do you create a project from the New dialog(there are so many options)
thanks
|
|
|
|
|
It depends on the type of project that you want. If you are simply creating a C++ project that you would like to run from the command line, you will want to select:
WIN32 Console Application
If this will be a windows program choose:
WIN32 Application
Then if it will be a windows application with ATL support choose:
ATL COM Appwizard
Or if you would like MFC support:
MFC Appwizard
you can also create DLLs in order to use your c++ classes from an external executable, in this case simply select the correct project to create the DLL for you.
You can add this project to an existing Workspace that you are working in and have multiple projects to a single workspace by checking the Add to existing workspace checkbox if that choice is available.
Say that you add all of your files into a DLL, and you want that DLL to link into another project in the same workspace, you will go into the project settings for the executable, and click the link tab. Then on the Object/libaray modules edit box, add the name of your DLL project .lib to the line. this will enable the Linker to find all of the exported items from your DLL.
If this does not answer your question please reply.
|
|
|
|
|
yeah i want to use command line!
so i guess i'll just go ahead and use the WIN32 Console Application
right?
thanks again!
|
|
|
|
|
I have a class that formats a string and I am trying to send it to the dialog class.
CNetServerDlg* pNetServer = static_cast<CNetServerDlg*>(AfxGetMainWnd());
pNetServer->PrintLog(strLogOutput);
the strLogOutput is a CString and PrintLog is a function that processes the code. The problem is that PrintLog never gets called. Is there something wrong with the above code or is something else wrong?
- Matt Newman
-Sonork ID: 100.11179:BestSnowman
Frankly AOL should stick to what it does best: Fooling millions of americans into believing that it, AOL, is the web. -Paul Watson
|
|
|
|
|
Have you stepped through with the debugger to see if your static cast is even being called? Because it seems that execution is not even reaching that point. Unless you are using exceptions and the static_cast is throwing an exception.
I need more info to answer your question.
|
|
|
|
|
What I am trying to do is create a dialog app using PJ Naughter's w3mfc class. I am converting his demo to a dialog app and can't get it to work. http://www.codeproject.com/internet/w3mfc.asp
I am trying to get PostLog to send info to my dialog. You can check out the demo if I'm not making sense.
- Matt Newman
-Sonork ID: 100.11179:BestSnowman
Frankly AOL should stick to what it does best: Fooling millions of americans into believing that it, AOL, is the web. -Paul Watson
|
|
|
|
|
I figured it out. The function I was calling PrintLog from wasn't being called.
Thanks for trying though.
- Matt Newman
-Sonork ID: 100.11179:BestSnowman
Frankly AOL should stick to what it does best: Fooling millions of americans into believing that it, AOL, is the web. -Paul Watson
|
|
|
|
|
Try this Matt:
CNetServerDlg* pNetServer = (CNetServerDlg*)AfxGetMainWn();
pNetServer->PrintLog(strLogOutput);
Other than that, If doesn't work let me know what you come up with? I usually create a function in the parent class of the dialog that I use to pass the information to the dialog.
|
|
|
|
|
For everyones information:
Jay Beckert wrote:
CNetServerDlg* pNetServer = (CNetServerDlg*)AfxGetMainWn();
pNetServer->PrintLog(strLogOutput);
is the same as:
CNetServerDlg* pNetServer = reinterpret_cast<cnetserverdlg*>(AfxGetMainWn());
pNetServer->PrintLog(strLogOutput);
reinterpret_cast simply says to the compiler "I know what I am doing, just go ahead and trust me."
Basically what you are doing is telling the compiler to use convert one data types binary format into another format that is completely different and may not even be compatible.
static_cast is safer because you are saying to the compiler, "I would like to conver this pointer to a compatible type." If that compatible type does not exist, then you will get a compiler error.
|
|
|
|
|
kilowatt wrote:
reinterpret_cast simply says to the compiler "I know what I am doing, just go ahead and trust me."
Basically what you are doing is telling the compiler to use convert one data types binary format into another format that is completely different and may not even be compatible.
static_cast is safer because you are saying to the compiler, "I would like to conver this pointer to a compatible type." If that compatible type does not exist, then you will get a compiler error.
Yes you are correct. I just tried this and had the same result as Matt's problem. I did a cheap hack to get around it. Hopefully we can hear from him how he came to a solution?
|
|
|
|
|
Jay Beckert wrote:
Yes you are correct. I just tried this and had the same result as Matt's problem. I did a cheap hack to get around it. Hopefully we can hear from him how he came to a solution?
No solution yet but I will let you not what happens
- Matt Newman
-Sonork ID: 100.11179:BestSnowman
Frankly AOL should stick to what it does best: Fooling millions of americans into believing that it, AOL, is the web. -Paul Watson
|
|
|
|
|
I figured it out. The function I was calling PrintLog from wasn't being called.
Thanks for trying though.
Jay Beckert wrote:
CNetServerDlg* pNetServer = (CNetServerDlg*)AfxGetMainWn();
pNetServer->PrintLog(strLogOutput);
Thats what I ended up using. Thanks for the help.
- Matt Newman
-Sonork ID: 100.11179:BestSnowman
Frankly AOL should stick to what it does best: Fooling millions of americans into believing that it, AOL, is the web. -Paul Watson
|
|
|
|
|
Matt Newman wrote:
CNetServerDlg* pNetServer = (CNetServerDlg*)AfxGetMainWn();
pNetServer->PrintLog(strLogOutput);
Thats what I ended up using. Thanks for the help.
Quick question Matt. How is your dialog being created?
I had the same problem and I NEVER did get it to work in one of my projects. I was using a dialog with an edit control that served as a log that just recieved strings and nothing else.
CNetServerDlg* pNetServer = (CNetServerDlg*)AfxGetMainWnd();
pNetServer->PrintLog(strLogOutput);
I know that is supposed to work, but didn't for me? LOL
|
|
|
|
|
Jay Beckert wrote:
Quick question Matt. How is your dialog being created?
I'm not sure what you mean. The class can't start until after the dialog is created.
- Matt Newman
-Sonork ID: 100.11179:BestSnowman
Frankly AOL should stick to what it does best: Fooling millions of americans into believing that it, AOL, is the web. -Paul Watson
|
|
|
|
|
Matt Newman wrote:
Quick question Matt. How is your dialog being created?
I'm not sure what you mean. The class can't start until after the dialog is created.
Sorry. What I was getting at is it a modal or modeless dialog. Could I still call a function with in the dialog class regardless of modal or modeless?
|
|
|
|
|
this is rotation around Z (Plane figure)
newx:=x*cos(angle) - y*sin(angle));
newy:=x*sin(angle) + y*cos(angle));
How to rotate the figure around x and y?
So, how changes newx and newy in this case. I have x,y,z Coordinates,
but i have only two coordinates (newx and newy) to paint the figure at the screen
|
|
|
|
|
In order to do this properly you will need to view this problem as having two different coordinate spaces. The world coordinate space, and the screen coordinate space.
You will need to create a four parameter point to hold these values [X,Y,Z,W]. X,Y, and Z are self explanitory, however you will need the W parameter for homogenizing. This means to keep all of the other values in proportion after you transform the points from you 3D worldspace to your 2D screen space. In most cases W will be 1, but will be modified after you perform some sort of transformation on it (I will explain the rotation transformation below). After you perform a transformation you will want to normalize the vector that represents your point and replace the homonginized value in W with a 1.
The conversion between the 3D world space and 2d screen space is a little complicated to explain right now, and I do not remember the exact formulas in the top of my head, however you could probably find them without trouble on the graphics newsgroup comp.graphics.algorithms, try searching google newsgroups.
In order to rotate around the X or the Y access it is easiest to view this if you create a 4x4 matrix.
M11 M12 M13 M14
M21 M22 M23 M24
M31 M32 M33 M34
M41 M42 M43 M44
If you start with the identity matrix:
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
Then add the particular parameters for the axis of rotation that you want to perform, you will create a transformation matrix. Here are the three matrices that you will use to rotate around the
X, Y, and Z axis respectively.
X
1 0 0 0
0 cos(angle) -sin(angle) 0
0 sin(angle) cos(angle) 0
0 0 0 1
Y
cos(angle) 0 sin(angle) 0
0 1 0 0
-sin(angle) 0 cos(angle) 0
0 0 0 1
Z
cos(angle) -sin(angle) 0 0
sin(angle) cos(angle) 0 0
0 0 1 0
0 0 0 1
You will place your point at the right of your transformation matrix and perform a multiplication, the result will be a point that is rotated around the origin by the specified angle.
M11 M12 M13 M14 X
M21 M22 M23 M24 Y
M31 M32 M33 M34 Z
M41 M42 M43 M44 1
I know this was a fast introduction to a 3d rotation, however there is quite a bit o ground work that needs to be done in order to get a set of points that are located in 3d space to be properly shown on a 2d screen and to have the perspective of the image preserved.
There are quite a few sites on the internet that have good descriptions of the math and the transformations that are involved.
If you have any more questions feel free to ask.
|
|
|
|
|
I need to analyse some code from a txt file but I don't know how
to read it . I'd like to now the easyiest way to do so .
thanks
Pierre
|
|
|
|
|
magpierre wrote:
I need to analyse some code from a txt file but I don't know how
to read it .
Like personally, or under the debugger or profiler..?
Windows notepad? perhaps just rename the file to cpp and view it under VC++ so you get all that pretty syntax hiliting
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|