|
Try running it in the debugger to check that you actually have some data and that it is being written to your file.
It's time for a new signature.
|
|
|
|
|
Thanks for your answer Richard. I tried running in the debugger. I do have some data to write to the file. How can I check whether it is actually written to the file? When I check the file in Windows Explorer it stays at 0kb.
|
|
|
|
|
I don't know what is happening with your file, I just tried a similar test and the file was written correctly. All I can suggest is that you step through your program to ensure the values actually get written, and also that no other part of your program destroys the file.
It's time for a new signature.
|
|
|
|
|
That's strange. I'll try it on another computer, maybe that helps.
Thanks a lot for your help anyway!
|
|
|
|
|
Hi,
two guesses:
1. you are looking at the wrong folder; is it a relative path? is your current directory what you think it is? add a w->Write(1); early on to make sure there is some data, so the file size and modifiction date must change.
2. not sure what Convert::ToString(fileName) is supposed to do. Have a go with a simple "aha.dat"
|
|
|
|
|
Hi Luc,
I found out that something was going wrong with my fileName indeed. Its working now.
Thanks a lot for your help!
|
|
|
|
|
As I suggested yesterday, you should always run through your code with the debugger to ensure that all your variables contain the correct values. When you said the file size was zero, you did not mention that the create time had not been changed. That would have been a good clue that the file was not being written.
It's time for a new signature.
|
|
|
|
|
Well, the file was actually written, so the create time changed. It was only the referece where to write the data to that as wrong, and that I didn't catch when stepping through the code. But now it works.
Thanks again for the help!
|
|
|
|
|
I'm still learning about generics so I create a generics function like this :
generic<class T> where T : ValueType
T Process(T val)
{
val = val * 15;
return val;
}
and called float a = Process<float>(10.0) , but then I got " error C2296: '*' : illegal, left operand has type 'T' " in the line val = val * 15; . Then I try a simpler method like this :
generic<class T> where T : ValueType
T Process()
{
T val = 15;
return val;
}
Called float a = Process<float>() and I still got "error C2440: 'initializing' : cannot convert from 'int' to 'T' " in the line T val = 15;
What is the correct way to use generics?
Thanks in advance
|
|
|
|
|
Anybody?
|
|
|
|
|
The problem in your code is that you cannot convert an int to a ValueType . T is a ValueYype , so you can use only the methods defined in that class when using objects of type T .
What are you trying to achieve?
|
|
|
|
|
Thanks for your reply,
Actually I want to make a 2D matrix class that doesn't just limited in one type (ValueType) only so that I can create a Matrix<float> or Matrix<int> depending on what I need. I thought that generic is the most appropriate and also the simplest solution but it turns out that I was wrong.
|
|
|
|
|
Unfortunately C# generics are not C++ generics, C# doesn't support numeric generics because there is no common base class of int/float/whatever that support calculation operations. You can do it the old manner, creating a class for every type you wish to support. There is another solution that uses generics in a different manner here[^].
|
|
|
|
|
Hi, im using C# dll in VC++ application.I have somedetails in VC++ like
PageNumer
pageTitle
PageDesc
BoxDetail .
I have to pass this to C# Dll. So i made one structure in VC++,then i pas that to C#.But i could't do that.Pls help me.
VC++ Function:
struct SCS3OverVwPg
{
__int32 iOvrPgNo;
char sOvrPgTitle[30];
};
void CToolTab::SendOverview()
{
SCS3OverVwPg *pOverVw = 0;
pOverVw = new SCS3OverVwPg;
Globals1::gwtoolbar->SetTree(pOverVw);
}
C# function:
public struct SCS3Over
{
Int32 iOvrPgNo;
char[] sOvrPgTitle;
}
public void SetTree(SCS3Over x)
{
MessageBox.Show("Data received");
}
If i do like this,it shows error error C2664: 'Tabcontrol::ToolBar::SetTree' : cannot convert parameter 1 from 'SCS3OverVwPg *' to 'SCS3Over'
If i change name in C# dll to SCS3OverwPg, it show error of structure redifinition Pls help me.
Anu
|
|
|
|
|
the structure (SCS3Over ) in c# dll is public? if it's public you can directly use it in visual c++ without having to redeclare it...so your visual c code:
void CToolTab::SendOverview()
{
Globals1::SCS3Over tmp;
tmp.iOvrPgNo=1;
tmp.sOvrPgTitle="ciao";
Globals1::gwtoolbar->SetTree(tmp);
}
|
|
|
|
|
Hello everyone,[it may not be the correct place to ask but in case some one has an idea, please] I am wondering if any one know or can help me how to convert regular windows program to windows ce. My application is written in VS C++ 2005 and another one is in C#. What I am trying to do is convert both of the application and deploy into windows ce device.
Thanks
|
|
|
|
|
Ive been on this for 3 hours now something I thought that was going to be easy isnt
I have a richtextbox control that contains a rtf file (that cant be edited) in the form and Im wanting to print that somehow.
It doesnt seem easy to do, is there a short tutorial somewhere?
thanks zed
|
|
|
|
|
Hi,
RTB is one of those Controls that don't print right away; they need some Win32 assistance. See here[^].
|
|
|
|
|
Thanks Luc, Ill look into that
seems wierd that RTB doesnt support printing cause if u would make a list of what controls you would like to have printing functionality it would be at the top of the list!
I might just ignore RTB and use a webbrowser widget instead (since that supports printing)
|
|
|
|
|
hi friends,
i want to use datagridview in c++, i am using data binding. i add object list to binding and use this binding as data source to gridview. then i set the the dataPropertyName as the member of the object.
my problem is i am not able to view my data in the grid. at runtime i want to add objects to the binding so that they can be viewed in the grid.
my code is as below
//bs is the binding object
for(int j = 0; j< CustInfo.oCust->Customer->Count;j++)
bs->Add(gcnew CustomerDetails(custobject));
CustGridView->DataSource = bs;
DataGridViewColumn^ column1 = gcnew DataGridViewTextBoxColumn();
column1->DataPropertyName = "m_strName"; // member of CustomerDetails
column1->Name = "Name";
column1->Width = 227;
CustGridView->Columns->Add(column1);
DataGridViewColumn^ column2 = gcnew DataGridViewTextBoxColumn();
column2->DataPropertyName = "m_strStreet"; //// member of CustomerDetails
column2->Name = "Street";
column2->Width = 120;
CustGridView->Columns->Add(column2);
can any one help
thanks in anticipation
Regds
Samir
|
|
|
|
|
Hi,
I'm quite new to C++/CLI and ran into a problem. I'm trying to get data from some textboxes on a form, for use in another source file. I think the best way to do this is to make a method in the form code which gets the textbox data and passes is to the source file when called. However, somehow I cannot get this working. Can anyone maybe point me in the right direction?
Any help would be great!
|
|
|
|
|
is there some reletion between the first form and the second form....
do the first form generate the second form or the second form generate the first?
|
|
|
|
|
Actually the code in which the data from the form is needed is no form itself. There is no relation between the form and the source file in which the data from the form is to be used.
I hope this makes it clear.
|
|
|
|
|
google for this....and you'll find the solution
[DllImport("user32.dll")]
extern IntPtr FindWindow(String^ lpClassName, String^ lpWindowName);
once you have the pointer to the data's form, you have several way to get the data
|
|
|
|
|
I'll have a go with that at Google. Thanks for your help!
|
|
|
|