|
Thanks. I'll do a quick sample test project to check the speed between the two methods.
The std::set insertion technique works fine (just finished the coding), but I suspect that it is not the fastest way of doing this.
I Dream of Absolute Zero
|
|
|
|
|
Hi all,
I crated a new dialog called IDD_RIPORTO.
I also added a class called riporto.
If i do:
riporto temp;
temp.DoModal();
everything is ok, but if i do:
riporto* temp = new riporto();
temp->Create(IDD_RIPORTO,this);
the application runs but crashes at runtime
when the above code is executed.
If i do:
CDialog *temp = new CDialog();
temp->Create(IDD_RIPORTO,this);
everything goes well but of course
i have no access to riporto data members,
so i think this isn't the correct way.
Where i go wrong ?
Thank you so much,
Deamo16.
|
|
|
|
|
Desmo16 wrote: riporto* temp = new riporto();
temp->Create(IDD_RIPORTO,this);
Read the article in MSDN regarding modeless dialog.
It clearly say that, you need customized contructor to create that dialog.
the default constructor of you dialog class calls CDialog(IDD); to initialize the dialog with template.
Desmo16 wrote: temp->Create(IDD_RIPORTO,this);
you are trying to create on already created object. So it wont work.
define you own contructor to create modeless dialog. never allow contructor to create dialog with template if you are looking for a modeless dialog.
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
<blink>My Blog | Understanding State Patte
|
|
|
|
|
when you run Domodal() is ok but when you use create you get error or no?
whitesky
|
|
|
|
|
when i use create i get error at runtime.
I'd like to understand how to write my own
constructor as i was told to do in the previous post
or if there's a sample coda somewhere.
|
|
|
|
|
You using
riporto* temp = new riporto();<br />
temp->Create(IDD_RIPORTO,this); and you get error
and if you use this way you get error or no and answer to me,please
<br />
riporto* temp = new riporto(this);<br />
riporto::riporto(CWnd* pParent )<br />
: CDialog(CTest2::IDD, pParent)<br />
{<br />
BOOL o=Create(IDD,Parent);
}<br />
whitesky
|
|
|
|
|
riporto * dlg;
dlg = new riporto(this);
dlg.create(IDD_RIPORTO);
dlg->ShowWindow(1);
tell me wheather it works or not
Ashish Dogra
MCA
Noida
|
|
|
|
|
i tried both methods but with no success.
|
|
|
|
|
is there somwthing wrong in the fact that i don't create the class "by hand"
but use the wizard ?
|
|
|
|
|
when you used from this code do you use breakpoint and yes whats error?
whitesky
|
|
|
|
|
CMyDialog* pDialog;
void CMyWnd::OnSomeAction()
{
//pDialog initialized to NULL in the constructor of CMyWnd class
pDialog = new CMyDialog();
//Check if new succeeded and we got a valid pointer to a dialog object
if(pDialog != NULL)
{
BOOL ret = pDialog->Create(IDD_MYDIALOG,this);
if(!ret) //Create failed.
AfxMessageBox("Error creating Dialog");
pDialog->ShowWindow(SW_SHOW);
}
else
AfxMessageBox("Error Creating Dialog Object");
}
//copy from MSDN
Use the WS_VISIBLE style in the dialog-box template if the dialog box should appear when the parent window is created. Otherwise, you must call ShowWindow. For further dialog-box styles and their application, see the DLGTEMPLATE structure in the Platform SDK and Window Styles in the MFC Reference.
Huynhnb
.: Your success is also me :.
|
|
|
|
|
if you have a class Dialog you can use
<br />
riporto * dlg;<br />
dlg = new riporto();<br />
dlg->create(IDD_RIPORTO);<br />
dlg->ShowWindow(1); <br />
whitesky
|
|
|
|
|
Desmo16 wrote: temp->Create(IDD_RIPORTO,this);
Move the call to Create() to the constructor:
riporto::riporto( CWnd* pParent ) : CDialog(riporto::IDD, pParent)
{
Create(IDD);
} Now you can create and display the dialog via:
riporto *pDlg = new riporto;
pDlg->ShowWindow(SW_SHOW);
...
pDlg->DestroyWindow(); Desmo16 wrote: the application runs but crashes at runtime
Have you narrowed the "crash" down to a single statement?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i've got a trouble calling Create()
the error is:
"riporto::Create": impossible converting parameter 1 from "int" to "LPCTSTR"
|
|
|
|
|
I have a function in cpp file returning int * array and taking int * array as a parameter. It is as:
int * funcArg(int *a ) {
int DLLArg [] = {100,200,300};
a=DLLArg;
return a;
};
I have exported this function in the dll (i have checked it with dumpbin.exe)
But I can not handle this function in c# client. My code in c# is as: ( ıt gives this error. "An unhandled exception of type 'System.Runtime.InteropServices.SafeArrayRankMismatchException' occurred in CSharpClient.exe
Additional information: Safe array of rank 51241 has been passed to a method expecting an array of rank 1."
What should I do? URGENT help!!!
namespace CSharpClient
{
class Class1
{
[DllImport("DenemeNonMfcDll.dll",EntryPoint="?Sub@DLLclass@@QAEHHH@Z")]
public extern static int Sub(int a, int b);
[DllImport("DenemeNonMfcDll.dll")]
[return: MarshalAs(UnmanagedType.SafeArray)]
public extern static int [] funcArg(int [] a);
public static int [] intArray = new int [3] {0,1,2} ;
static void Main(string[] args)
{
foreach (int num in funcArg(intArray) )
{
System.Console.WriteLine(num.ToString());
}
Console.WriteLine("Press any key to continue...");
Console.ReadLine();
}
}
}
|
|
|
|
|
You are trying to return a pointer to an array on the stack. There is no guarantee that your array will still be there when your function returns. You are passing in a parameter "int *a" which you never use.
Was this your intention?
int * funcArg(int *a)
{
a[0] = 100;
a[1] = 200;
a[2] = 300;
return a;
};
Most people usually have another parameter for the calling function to tell the callee the size of the array being passed so the callee won't exceed the buffer.
|
|
|
|
|
My aim is to write a function returning int array and taking an int array as a parameter such as
int * funcArg(int *a){
return a;
};
I will export it from c++ dll and I will use this function in c#. I will call it like
[DllImport("DenemeNonMfcDll.dll")]
[return: MarshalAs(UnmanagedType.SafeArray)]
public extern static int [] funcArg(int [] a);
But C# can not handle it this way. And I coul not find a way doing this. Either I can change c++ code or c# code. But I could not find a solution to make an interoperation between c++ and c#
|
|
|
|
|
|
Remove the default border if necessary
OnPaint, or in OnEraseBkgnd draw a line
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
<blink>My Blog | Understanding State Patte
|
|
|
|
|
i dont know how to remove and how to add so can u send me code for this
thanks
Ashish Dogra
MCA
Noida
|
|
|
|
|
Right click on a dialog box while in design mode and see if a menu pops up. If it does so, then see what is there with it. Nobody will *send* you the code for anything. You may have to code and when you run into trouble someone can help you.
You have an apple and me too. We exchange those and We have an apple each.
You have an idea and me too. We exchange those and We have two ideas each.
|
|
|
|
|
You can use ModifyStyle function to remove or add a window style and ModifyStyleEx for add/remove extended style.
for removing border, ModifyStyle(WS_BORDER,0);
for removing caption ModifyStyle(WS_CAPTION,0);
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
<blink>My Blog | Understanding State Patte
|
|
|
|
|
thanks for your reply
but can you tell me how can i add at the bottom of dialog box as in the Windows XP and i want to add some button on it
and with ModifyStyle(WS_BORDER,0); the dialog box upper bar willbe inactive but not disappear
thanks
Ashish Dogra
MCA
Noida
|
|
|
|
|
check MSDN for more details about windows styles.
in the OnPaint function,
CPen pen;
pen.CreatePen(PS_SOLID,GetSystemMetrics(SM_CXDLGFRAME),GetSysColor(COLOR_ACTIVEBORDER));
dc.SelectObject(pen);
CRect rect;
GetClientRect(rect);
dc.MoveTo(dsierd_x_pos,desired_y_pos);
dc.LineTo(xpos,ypos);
do the necessary claculation to draw your line
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
<blink>My Blog | Understanding State Patte
|
|
|
|
|
What do you need exactly? if you answer to me then you dont need to asked this question everyday
whitesky
|
|
|
|