|
hi,
Can Anybody tell me how to write a list control data in text file in MFC?
|
|
|
|
|
CListCtrl has member functions like GetItem() , GetItemData() , etc., and there's CFile that you can use to write to file. Where exactly are you stuck?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi!
I have an array of pointers, which point to classes derived from the same class. I also have a pointer, that points to the array. Is there a simple way to find out to which element of the array this pointer points to, or shall i use a variable in the base class for this purpose?
Thanks
|
|
|
|
|
You may use RTTI [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Actually, this solves another problem of mine, so thanks a lot However, I'd like to know, whether the pointer points to the 2nd, 5th, nth element of the array. If I understand the description correctly, type_info only gives me the name of the class my pointer-in-the-array points to (right?). First I thought of using sizof(), but my derived classes are of different sizes.
|
|
|
|
|
Please post the relevant code (I need to know the pointer relationship with the array).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I have a base class, let's say Car, and derived classes BMW, Mercedes, Renault, etc.
The array is: Car* p_Cars[2][16];
The pointer: Car** pCar;
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 16; j++)
{
if (j==2 || j==3)
p_Cars[i][j] = new BMW(i, j);
else if (j==4 || j==5)
p_Cars[i][j] = new Mercedes(i, j);
.
.
.
}
}
So I'd like to know, whether I can determine the element from its address.
I hope you understand my problem, i tried my best 
|
|
|
|
|
A given value of pCar refers to the element p_Cars[i][j] (i.e. pCar == &p_Cars[i][j] holds true), provided i,j are computed as follows:
int k = (int) (pCar - &p_Cars[0][0]);
int i = k / 16;
int j = k % 16;
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
You are welcome.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
So....you have:
CBase* pArray[] = { whatever... };
CBase* pItem = address_of_some_item_in_the_array; ?
In that case:
const size_t index = pItem - pArray;
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
Hi,
May i know how to check if a folder or file exists and if not create a folder....
im using ...
CString csPath1="C:\\Temp\\myfolder";
if(_access (csPath1+_T("\\Test"), 0)==-1);
::CreateDirectoryW(csPath1+L"\\Test",NULL);
and im getting the below error....
'_access' :cannot convert parameter 1 from 'ATL::CStringT<BaseType,StringTraits>' to 'const char *'...
Please help me......(myproject is in unicode)
|
|
|
|
|
Why do you need to check first?
CreateDirectory will return ERROR_ALREADY_EXISTS if the directory already exists.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Thanks for ur help and please let me know how can i check whether a file(not directory) exists....(my project is in unicode)........
|
|
|
|
|
You can use PathFileExists()[^] function (works with both folders and files).
The page contains a sample as well - saves me from typing code. Do remember to include shlwapi.h and link to shlwapi.lib .
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
How can I use DLL file in C#.NET ? I create dll in Borland C++ Compiler 5.5.1 and using C language.
Following code is not work.
My C Code;
-----------------------------------------------------
//hello.dll
#include <windows.h>
extern "C"
{
void __declspec (dllexport) function1()
{
MessageBox (NULL, "test message","test title",0);
}
}
BOOL WINAPI DllMain (HINSTANCE, DWORD, LPVOID)
{
return TRUE;
}
My C# Code;
-----------------------------------------------------
[DllImport("C:\hello.dll")]
public static extern void function1();
private void button1_Click(object sender, EventArgs e)
{
function1();
}
|
|
|
|
|
Ok, I try this; But I get this error: Entry Point Not Found
C DLL CODE
-----------------------------------------------
#include <windows.h>
BOOL __stdcall DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID lpReserved) {
return TRUE;
}
__declspec(dllexport) void __stdcall Message(char* p_szMessage) {
MessageBox(NULL, p_szMessage, "Message from DLL", MB_OK);
}
C# DLL CODE
-----------------------------------------------
[DllImport("filename.dll")]
static extern void Message(string msg);
private void button1_Click(object sender, EventArgs e)
{
Message("Hello world");
}
|
|
|
|
|
What does it mean, specifically, 'it doesn't work' (i.e. more details needed)?
BTW you possibly would get better help at C# forum.
BTW2: I saw you've already cross-posted your question...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
cross-posted is forbidden? Because this question related about between c and c#.
How can I "dumpbin -exports dll" in borland c++ 5.5.1 compiler on command prompt?
Do you have any idea?
|
|
|
|
|
Hi,
how do we send structure data on tcp socket ?
any code snippets ?
Jalsa
|
|
|
|
|
jalsa G wrote: how do we send structure data on tcp socket ?
Just like any other binary data.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
It doesn't matter what you're sending, just make sure the size of data is mentioned correctly.
You may need to typecast the data as char* 'cause that's what the function accepts.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
«_Superman_» wrote: It doesn't matter what you're sending
Provided you're not sending pointers...
--Carlo the Nitpick.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Also, an old Greek mythic legend states that you cannot (and should not) send tomatoes on socket.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|