|
Hi,
I need to create a file inside the directory.I have to get the directory name and file name from the textbox. How to do this ? Can you help me.
Note:-
I can able to create a file(getting the file name from the textbox).
I can able to create a directory also(getting the directory name from the separate textbox).
|
|
|
|
|
Specify the full path to the file when you create it. Otherwise, you will create it in your working directory
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
I am creating a modeldialogbox,I wrote the code as follows.
void Mform::newToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
Form ^dlgl= gcnew Form();
this->btn = gcnew Button();
this->btn->Text = L"OK";
this->btn->Location = System::Drawing::Point(100,160);
this->btn->Click += gcnew System::EventHandler(this,&Mform::bt1_Click);
this->label = gcnew Label();
this->label->Text = L"Enter the filename : ";
this->label->Location = System::Drawing::Point(45,20);
this->label->Size = System::Drawing::Size(113,13);
this->textbox = gcnew TextBox();
this->textbox->Location = System::Drawing::Point(178,20);
this->textbox->Text = "";
this->textbox->Multiline = true;
this->textbox->AcceptsReturn = true;
this->textbox->AcceptsTab = false;
this->textbox->WordWrap = true;
dlgl->AcceptButton=btn;
dlgl->CancelButton = btn1;
dlgl->MaximizeBox = false;
dlgl->MinimizeBox = false;
dlgl->Controls->Add(this->btn);
dlgl->Controls->Add(this->btn1);
dlgl->Controls->Add(this->label);
dlgl->Controls->Add(this->textbox);
dlgl->ShowDialog();
}
void Mform::bt1_Click(System::Object^ sender, System::EventArgs^ e)
{
this->rtext = gcnew RichTextBox();
String ^path1;
path1=textbox->Text::get();
if(path1 == "")
{
MessageBox::Show("Enter the filename","Error",MessageBoxButtons::OK);
}
else{
FileInfo ^fi = gcnew FileInfo(path1);
if(fi->Exists)
{
MessageBox::Show(" filename exists","Error",MessageBoxButtons::OK);
}
else
{
FileStream ^fs = fi->Create();
this->f = gcnew Form();
this->f->MdiParent = this;
this->f->Show();
this->rtext->Dock = DockStyle::Fill;
this->f->Controls->Add(this->rtext);
}
}
}
In this code when i press ok button, it perform needed the operation but the dialog box is not closed.
help me. where i done a mistake.
|
|
|
|
|
In Winforms, you need to either close the form in code, or set the AcceptButton and CancelButton properties, etc, in the forms designer, to set up which button(s) close the form.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
Can you tell me how to create a model. I need a step by step process.
I read msdn already i couldn't understand. Can you guide me.
Thanks,
|
|
|
|
|
Do not repost your questions. it's rude.
led mike
|
|
|
|
|
I am doing project using visual c++ 2005 clr windows form application.I used a treeview& a contextmenustrip. On right clicking the rootnode the strip contains "Add&Find" item.I need some code samples to add & find a node using visual c++.Send me the same.
Thanks in advance
|
|
|
|
|
readwrite wrote: I need some code samples to add & find a node using visual c++.Send me the same.
I see you are new to CodeProject, welcome.
As to your request you should read the first post in the Visual C++ / MFC forum titled "How to get an answer to your question". Pay attention to item #2. Also this Posting Guidelines Article[^] might be helpful as well.
led mike
|
|
|
|
|
Hi,
I am trying to create a model dialog box "in managed c++".
I don't know the basic steps.
Can you give the steps,and tell how to add this to form.
I read the msdn already. I couldn't understand.
Helpme.
Thanks,
rose
|
|
|
|
|
rose196 wrote: Can you give the steps,and tell how to add this to form.
I read the msdn already. I couldn't understand.
"The following code example creates a new instance of a Form and calls the ShowDialog method to display the form as a dialog box."
They hide those samples in the documentation[^]
led mike
|
|
|
|
|
Hi,
Thanks for replaying.
I did already,as per the example,but i have a problem.
Actually i am developing IDE.
when i was pressing the new button the dialogbox has to be open.
My problem is when i press ok button in the dialodbox it perform some operation at the same time it has to be close know,but in my project it is not closed but it perform the needed operation. if i give close to close the dialogbox, the entire form was closed.
Now what i have to do.
Thanks
|
|
|
|
|
I am searching for files in a particular drive..
However, the search is very slow..
Can I use threads to accomplish this??
Can anybody tell me how to do this or send me a helpful link??
|
|
|
|
|
ptr2void wrote: However, the search is very slow..
Can I use threads to accomplish this??
So are you assuming that using threads will speed up the process?
led mike
|
|
|
|
|
Yes I am assuming that threqads would make it faster..
Am I wrong? Please correct me..
Since I am using recursion, If I can spawn a thread whenever a new directory is found I am assuming that the search would be faster..
Please correct me if I am wrong and it would be very helpful if you could guide me in some way as to how the search could be faster..
|
|
|
|
|
ptr2void wrote: Yes I am assuming that threqads would make it faster..
Am I wrong?
No you are not wrong, um Yes you are wrong. See it's just not that simple, threading never is and anyone who tells you different either doesn't know that they are talking about or is an absolute genius and therefore their experience does not apply to you and me.
Creating threads and switching context between them takes resources and processing cycles so technically can "slow down" a procedure. If the execution context ( hardware, running software ) provides a scenario where multiple processors are available and therefore can more efficiently execute your procedure then yes it could be faster (emphasis on "could" because multiple processors are not the only criteria in your case since there is still only one bus and one drive that you are accessing and therefore caching will come into play as well), otherwise it will just be slower. Now how do you determine if the execution context is favorable? There almost is no way. Also even when it is favorable, how much faster would it be? Don't know but in your case likely negligible.
This is really far more complex than I am qualified to explain but have I provided even a small explanation that helps?
led mike
|
|
|
|
|
Hi
How To using office Word 2003/2007 in Manage C++
|
|
|
|
|
Office Interop Library. Google for it and there is a lot on it...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Background: I'm trying to build a managed wrapper around a C library, using C++/CLI to build a DLL that will be referenced by a C# program. This is my first look to C++/CLI, so even little things seem really hard.
Now, my first problem. The C library has lots of parameters passed by pointers, e.g.:
void H5get_libversion(int * major, int * minor, int * release);
What I'd like to have is an equivalent method in C++/CLI, something that in C# would be:
void GetLibVersion(ref int major, ref int minor, ref int release);
The only way I found to achieve this is doing something like:
void HGlobals::GetLibVersion(unsigned int % major, unsigned int % minor, unsigned int % release)
{
unsigned int _major, _minor, _release;
H5get_libversion(&_major, &_minor, &_release);
major = _major;
minor = _minor;
release = _release;
}
Do I really have to do this manual "duplication"? Isn't there a better (shorter) way?
Thanks in advance
Luca
The Price of Freedom is Eternal Vigilance. -- Wing Commander IV
En Það Besta Sem Guð Hefur Skapað, Er Nýr Dagur.
(But the best thing God has created, is a New Day.)
-- Sigur Ròs - Viðrar vel til loftárása
|
|
|
|
|
Maybe try pinning those moveable managed "pointers" (tracking references)
void NativeFunc(int *a, int *b)
{
*a = 10;
*b = 20;
}
public ref class TestRefClass
{
public:
TestRefClass() {}
void TestMethod(Int32 %a, Int32 %b)
{
pin_ptr<Int32> pa = &a;
pin_ptr<Int32> pb = &b;
NativeFunc(pa, pb);
}
};
int _tmain()
{
int a = 3;
int b = 4;
TestRefClass obj;
obj.TestMethod(a, b);
return 0;
} Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi..
I am new to C++/CLI Programming..
I am using a user defined listbox and I am adding the items to it another method..
So the listbox dosent get dynamically painted..
I want to know is there any OnPaint() method for this??
Also do I have to make this listbox as DrawMode::OwnerDrawFixed ??
Kindly help..
|
|
|
|
|
The listbox will have a draw event that gets called to draw an item if they are owner drawn
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: The listbox will have a draw event that gets called to draw an item if they are owner drawn
Here is some code:
void SearchFiles::SearchFileByPath(LPCTSTR path, LPCTSTR filename, System::Windows::Forms::ListBox ^ objListBox)
{
//performing some logic
objListBox->Items->Add(System::String(path).ToString());/*here adding items*/
//here want to draw it by: objListBox->DrawItem();
/*what to add in System::Object^ sender , DrawItemEventArgs^ e ?*/
}
|
|
|
|
|
Okay let me explain my problem:
I have a form1.h in which I am initializing the listbox as follows:
void InitializeComponent(void)
{
this->obj = (gcnew System::Windows::Forms::ListBox());
this->obj->Location = System::Drawing::Point(0, 0);
this->obj->Name = L"obj";
this->obj->Size = System::Drawing::Size(120, 95);
this->obj->TabIndex = 0;
}
Now I am calling another function to add some items as follows:
sf->SearchFileByPath(path,filename,obj,sender,e);
And in that particualr function , I want that the listbox items should dynamically be shown as the program runs..
So I tried adding the ListBox::DrawItems(sender,e) ..
But the error is like:
cannot convert parameter 5 from 'System::EventArgs ^' to 'System::Windows::Forms::DrawItemEventArgs ^'
System::Windows::Forms::DrawItemEventHandler ^System::Windows::Forms::ListBox::DrawItem': event does not have a raise method
Please help me..
|
|
|
|
|
I build a system and run it on few nodes concurrently. I want the configuration status of the system on those nodes be the same when one of the nodes change it. Let say 3 nodes A,B and c. When A change a system configuration to on, then the system configuration of other nodes will be synchronized to on immediately. My friend tell me a concept, build a simple database with excel store the configuration status from those node, latest status will overwrite the old status, then each nodes refer to it. Can somebody gv me some hints how to make it? On codeproject did anyone see any article bind with this concept? I don't know what keyword to search. Thx
|
|
|
|
|
Hi
how to Convert Struct To Byte
|
|
|
|