|
It goes like this:
When I finished changing items in a ListCtrl I wanna make all the columns the actually width like I just double clicked the header-divider. But I don't know exaclty how to put codes in my program.
Anyone please help me figure it out or give me some tips.
Thanks very much! ^_^
|
|
|
|
|
CListCtrl *pLC = (CListCtrl *)GetDlgItem(IDC_MYLVCTRL);
pLC->SetColumnWidth(0,LVSCW_AUTOSIZE);
|
|
|
|
|
|
(first sorry if the topic doesnt fit to this board but i didnt find a better place)
Well,
Id like to have a class and derivate several classes from it. Then id like to have a container that could contain object from any of the derivated classes. Example:
class A {public: int a; virtual void print() {printf("a\n");}; };
class B:public A {public: void print() {printf("b\n");}; };
class C:public A {public: int b;};
int main(int argc, char* argv[])
{
A a; B b; C c;
vector <A> X;
X.push_back(a);X.push_back(b);X.push_back(c);
for (int i=0;i<x.size();i++) X[i].show();
// HERE I WANT TO CALL THE RIGHT print METHOD
return 0;
}
It might be basic but its been a long time im wondering how to do that,
any help would be greatly appreciated....
Remy
|
|
|
|
|
One solution is dynamic allocation.
// Assuming ClassA is base
std::vector<class a*=""> data;
A *a = new A;
data.push_back(dynamic_cast<classa>(a);
...
Kuphryn
|
|
|
|
|
Thanks Kuphryn,
My final goal is to insert that into a class. Wouldnt i have some memory problems if i do that?:
class A {public:int a;virtual void show() {printf("a\n");};};
class B:public A{public:void show() {printf("b\n");};};
class C:public A{public:int b;};
class CodeProject
{
public:
std::vector<a*> data;
void Init()
{
A *a = new A; data.push_back(dynamic_cast<a*>(a));
B *b = new B; data.push_back(dynamic_cast<a*>(b));
C *c = new C; data.push_back(dynamic_cast<a*>(c));
}
void Main()
{
Init();
for (int i=0;i<data.size();i++)
data[i]->show();
}
};
int main(int argc, char* argv[])
{
CodeProject Rulez;
Rulez.Main();
return 0;
}
|
|
|
|
|
No. Remember you are working with pointers. Just deallacate the memory after you're done. In other words, delete the pointers. One solution is to loop through all elements in the container and call "delete ..."
Kuphryn
|
|
|
|
|
Oups,
Well, lets say i was just testing your skills Kuphyn.
Thanks a lot again, its really useful for me.
Remy
|
|
|
|
|
Hi,
I'm writing an OCX in VC which passes a string containg NULLs. VB discards these NULL bytes. The length of the string shows as 0, when VC++ sends a NULL char. to the VB Event.
Can someone help me How to handle these NULLs in VB?
VC++, OCX event declared as ...
void FireWriteToPort(LPCTSTR portData)
VB handles it as ...
Private Sub ThreadOCX1_WriteToPort(ByVal portData As String)
... portData becomes empty when a NULL char. comes into picture.
Thanks in advance,
|
|
|
|
|
VB uses a null char to truncate the string with just like C/C++. If there is a NULL at the front of the string it will consider that the end of the string.
Look at the following code for an example of this...
Private Sub Form_Load()
Dim Message As String
Message = vbNullChar
Message = Message & "Oh, Happy "
Message = Message & vbNullChar
Message = Message & "Day"
ShowNull Message
End Sub
Sub ShowNull(ByVal Data As String)
MsgBox Data
End Sub
It will show a blank message box, but if you commment the line Message = vbNullChar it will output "Oh, Happy ".
Jeremy Falcon
|
|
|
|
|
Hello All,
I have a composite Activex control which has a few common window controls over it. Now I am trying to place this activex control over a normal mfc dialog generated through MFC Appwizard. The dialog does not get created at all neither does it run. Why. Am I missing something. Is this allowed in the first place.
I know with a MFC Activex control this works but how do I make it work for a Active x control generated through ATL. I have tried with Full Control too.
Regards
Rajdeep Majumdar
|
|
|
|
|
I remeber there is a article in codeguru or coderoject ever,but i can't find it.please give some tips.
|
|
|
|
|
How to take "argc" (like comand line) in dialog based aplication?
|
|
|
|
|
|
GetCommandLine() in MFC.
~RaGE();
|
|
|
|
|
If you are not using MFC, it's also in your WinMain () fuction...
WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
Jeremy Falcon
|
|
|
|
|
GetCommandLine returns you a string (LPTSTR) to command line including the program name, so you can parse it. If you use MFC you have CWinApp::ParseCommandLine(...) and CCommandLineInfo object which does the job for you
Gil
|
|
|
|
|
big thanks
|
|
|
|
|
What is the easiest way to keep track of users logged into a database for signing in and out.
Thanks
|
|
|
|
|
Hello, I have a big time trouble with displaying more than 16 color icons in report view in my listview. I create a image list and load a bitmap containing the images, but they display really ugly (I think in 16 colors), and from that time on, My listview control looks ugly. Any ideas on displaying them the way they are?
Please provide code snipets,
Thanks,
Deian
|
|
|
|
|
Deian Popov wrote:
Please provide code snipets
I was hoping *you* could provide the code you have used to initialise your imagelist, so that *we* can help you.
~RaGE();
|
|
|
|
|
Depends on the ILC_COLORxx value you used when calling the CImageList::Create method and whether the Bitmaps you loaded into the image list are compatible with that (the VC resource editor only works in 16 colors...)
|
|
|
|
|
Thanks for the help, yes it turned that I did not set up a flag in my image list (ILC_COLOR32) I think. After passing the right flag, I got my icons looking the way they are
Thanks,
Deian
|
|
|
|
|
I am currently researching how to implement a feature for an article I am working on. I need to be able to create, on demand, a new email address to receive incoming email. This address will be managed by an agent application which reads incoming email and acts upon it appropriately.
I could require that users have an email server of their own. If I do this, is it required to have a DNS entry and MX records and all that OR can I just send email to someone@127.0.0.1 and have my email server receive it with no MX/external internet stuff? Ideally, I would like to put the email server on a different port than the standard POP3/SMTP ports (like 9921). Could I send an email to someone@127.0.0.1:9921 or somehing like that? If so, would all or most all email clients be able to handle that?
This is the method I think I am going to use, but before I spend too much time on it, I am hoping someone in the CP community can tell me if this would work.
Thanks in advance.
|
|
|
|
|
I have an SDI application with a tree control set in a form. The tree control has pop-up menus that appear when you click on item in the tree. However, sometimes when I'm running the mouse up and down on of the pop up menus, the program just crashes. It's otherwise stable and functional. Any ideas? I realize this is one of those "random crash" questions but has anyone else experienced something similar and come up with a way to avoid it??
|
|
|
|