|
Yay!=) I actually made it work now, at least I think so. Instead of initiating a pointer to the class, I use normal creation.
Question myQuestions[MAX_QUESTIONS];
and also static is gone.
So I guess I was right about being "gone with the wind" with the Object part, but how would it look like if I used it as a pointer? How to make it work?
Thanks alot btw!
Best Regards,
Hmmkk
|
|
|
|
|
Oki, you answered the question even before I could post=)
Thanks alot, now I know how to initialize pointer objects too=)
You are a really kind man, sir. Thanks!
Best Regards,
Hmmkk
|
|
|
|
|
No worries - glad to help.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have two forms (Form1 and Form2). Form1 will create an instance of Form2. After some processing certain elements from Form2 will be passed back to Form1. I think I know what I need todo (roughly) but I have a problem including each Form header in the other. I don't think this is possible (is it?) so how do I go about creating instances of each form if I can't include their headers?
I know there was a similar post on this but it didn't answer my specific question.
Thanks in advance.
|
|
|
|
|
If you are including the same header to the forms, instead using #pragma once
use Old Defenition style Example:
#ifndef _CORE_H_
#define _CORE_H_
public __gc class Core
{
//To Do:
};
#endif //_CORE_H_
With this you can use it from anywhere and you can include header into any file. Or multiple file. you will not get redefenition error
|
|
|
|
|
I had a similar problem. I just created a class that I pointed both forms to and used it to pass information between the forms.
So creat a new __gc class. From form1 create an object of that class. then point it to form2's object.
Pass is the class i'm using to pass information.
<br />
Pass *pass = new Pass();<br />
Form2 *input = new Form2(); <br />
input->pass1 = pass;<br />
input->ShowDialog();<br />
<br />
label_InputSomthing->Text = pass->somthing;<br />
Invalidate();<br />
<br />
Pass *pass1;<br />
pass1->something = textBox_something->Text;<br />
<br />
Close();<br />
|
|
|
|
|
Thaks guys I'll give it a go.
Saksida - will the old style definitions go inside the namespace tag or outside. e.g
#ifndef _CORE_H_
#define _CORE_H_
namespace test
{ ... }
#endif
or
namespace test
{
#ifndef _CORE_H_
#define _CORE_H_
...
#endif
}
|
|
|
|
|
Do I need to use the #indef definition in both forms or jsut the main one?? If I use it in both I get errors.
error C2143: syntax error : missing ';' before '*'
error C2501: 'test::Form1::form2' : missing storage-class or type specifiers
error C2501: 'test::Form1::f2' : missing storage-class or type specifiers
When I try to declare an instance of form2.
If I use it in the main form only I get only one error.
error C2011: 'test::form2' : 'class' type redefinition
I could do with some help here. I'm not very experienced with c++ let alone managed c++. Been on this for a couple of days and nothing I try wants to work.
|
|
|
|
|
Make sure to #include both your passing class and form2 in your form1.
|
|
|
|
|
Yes you need to use but not #indef but #ifndef
And of course you need outside namespace. This means it must be in the beginning of file #ifndef and #define
And on the end it must be #endif
If you realy want to have an example then download this:
http://users.volja.net/bsaksida/CDDVD Organizer.zip[^]
Look under Core Folder, you will see CDDVDcore.h and you will see how has been defined. this program verzion is 0.1 there are a lot of bugs. Don't wory this program will be released as opensource.
|
|
|
|
|
Thanks for the help guys. I've written a little test prog that I've managed to get going with your help.
Thanks again.
|
|
|
|
|
Hi all,
I'm trying to create a few panels in a VC++.net application. I need the panels to be visible on a number of screens and I don't want to reproduce the same components many times over. When I run my app the panel is only visible in one screen only no matter what I do.
I'm doing something along the lines of
<br />
private: System::Void application_menuItem_Click(System::Object * sender, System::EventArgs * e)<br />
{<br />
this->application_panel->Visible = true;<br />
this->low_level_panel->Visible = false;<br />
}<br />
which works for one screen but not if I select any other screen.
Any ideas gratefully recieved.
|
|
|
|
|
What do you mean by a screen ? A form ? How does this panel get to be on these forms ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Sorry for the poor explanation.
I have a form (Form1), that has two panels on (panel1, panel2). This is where I'm becoming stuck. Each panel is supposed to show a number of components with some of these components being on both. I've grouped these components together and added them to another panel (panel3). Form1 has a menu item which is used to choose panel1 or 2.
So I have something like
<br />
private: System::Void menuItem1_Click(System::Object * sender, System::EventArgs * e)<br />
{<br />
this->panel1->Visible = true;<br />
this->panel2->Visible = false;<br />
}<br />
to show the appropriate panel. Now what I also need to do is add panel3 to the visible panel. So I'm doing - or trying to do - something like
<br />
if ( this->panel1->Visible == true )<br />
{<br />
this->Controls->Add( this->panel3 );<br />
}<br />
But I can only get panel3 to show itself on one panel. Either panel1 or panel2 but never both.
|
|
|
|
|
I'd have thought the trick would be to move panel3 to be top in the z-order, so it is always visible above panel 1 OR 2, without adding it to either, just because it's part of the form.
Otherwise, do they have to be the same instance ? Perhaps you could create a control, add it to both panels, and then pass the data between the two so they look the same in terms of what is set on them ? Or do it using events ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
So basically have panel3 floating over the other panels. How do you change the z-order (sorry but new to all this)? And will this then lock the panel to its correct location throughout the forms lifespan?
|
|
|
|
|
In managed C++ - use SetWindowPos to set the Z order to top. The panel shouldn't move, unless you tell it to.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
In MC++, use SetWindowPos with SWP_NOMOVE | SWP_NOSIZE and a position of TOP.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks for the help Christian.
|
|
|
|
|
Also i have noticed that if i change select statment, there would not be any effect.
|
|
|
|
|
I would like to make a programme that list active users that are connected to my pc.
How do i get access to these information.
What should i look into?
|
|
|
|
|
I have a button in a dialog which when clicked opens an OpenFileDialog box and the user can select a file. The problem I am facing is that when I try and copy the file & path using the FileName function into a CString, I keep getting a NULL value.
The thing is, the code works as intended in the debug mode but doesnt in the release mode.
Below is the code I am using:
void CDisColEnvDlg::OnBnClickedButtonLocalBrowse()
{
// TODO: Add your control notification handler code here
System::Windows::Forms::OpenFileDialog* appOpenFileDialog = new System::Windows::Forms::OpenFileDialog();
appOpenFileDialog->Filter = S"Trace File (*.tf1)|*.tf1";
if (appOpenFileDialog->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
CString szFileName = appOpenFileDialog->FileName;
AfxMessageBox(szFileName,MB_OK|MB_ICONINFORMATION,0);
}
}
Can anyone tell me what the problem potentially could be.
Also, is there a way to do this using unmanaged code?
Thanks in advance.
--
If a program is useless, it must be documented.
|
|
|
|
|
vajjalu wrote:
Can anyone tell me what the problem potentially could be.
The string in the dialog is probably wide, try using _bstr_t.
vajjalu wrote:
Also, is there a way to do this using unmanaged code?
Yes, these dialogs exist in MFC, CFileDialog or COpenFileDialog or something. You can get at them without MFC as well, by filling a struct and passing it to an API function, I believe.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
In your toolbox you have OpenFileDialog and SaveFileDialog. It's preaty easy to use it
|
|
|
|
|
Hi there!
I'm making an application using managed C++, and i'd like to know how
i could change the default appearance,with an easy way,(without using GDI+) of the form in something more presentable.(e.g adding some graphics). Is there any class that impements graphics or changes the resources of the form?
thanks in advance.
|
|
|
|