|
WM_ACTIVATEAPP would be appropriate. Why are you overriding PretranslateMessage? Why not to handle the message through MFC message map; use ON_WM_ACTIVATEAPP() inside the BEGIN_MESSAGE_MAP and END_MESSAGE_MAP pair. Also this is the prototype of the handler
void CMyDialog::OnActivateApp(BOOL , DWORD);
--
=====
Arman
|
|
|
|
|
Worked...
I do not understand why it did not worked inside the PreTranslateMessage...
Thank you for yuor feedback.
|
|
|
|
|
hello i am z1n i'm really interested in learning c++ so where should i go first hoping some of you vets could show me the best resource's?
|
|
|
|
|
A good free online resource is books by Bruce Eckel[^]
--
=====
Arman
|
|
|
|
|
|
Please refer this[^].
Regards,
Paresh.
|
|
|
|
|
|
If I have this code made in the Form.h of may project, how can i make the conection in
the main project file(.cpp) for variable "W".....please help.....can you give me a link or something like that where I can learn to do the conections between the variables from interface(form) and my algorithm(code)....
private: System::Void StartPackingbutton_Click(System::Object^ sender, System::EventArgs^ e) {
int W;//Container Width
try {
W=Convert::ToInt32(ContainerWidthtextBox->Text, CultureInfo::CurrentCulture);
}
int main()
{ int W;
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
Application::Run(gcnew Form1());
return 0;
}
|
|
|
|
|
|
Hi!
Can anyone tell me how can i return an int array from an exported function of DLL?
I have a function in VC++ Dll which is exported from DLL. This function will fill an int array and it should return to calling application(VC++ again).
Can anyone send me a sample code? or logic how this can be done?
And how the calling application should parse this array?
Thanks in advance.
|
|
|
|
|
A simple implementation could mimic standard Windows APIs GetWindowText , GetWindowsLength behaviour.
The Above APIs deals with char s instead of int s, but the underlying idea can be the same: accept a buffer allocated by the calling code (at least giving to the calling code the hint of required buffer length) and just fill it.
Hope that helps.
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.
|
|
|
|
|
|
Thanks much all of you.
My problem is solved.
I did a simple pass of array by "Passing a pointer(int* ReturArray()) to first element in the array". Then increment the pointer and retrive its contents on the application side.
It was a simple int array. so did not want to complicate things.
But did go throgh the links and saved for future use.
Good Info. Thanks again.
|
|
|
|
|
Hello,
I use CSortListCtrl to show some data in a list, and all informations come from a lokal files,
i have a vector to store all datas for CSortListCtrl!
The property LVS_OWNERDATA is set!
Vector is for my own class derived from CObject, have some CStrings and integers!
Like this:
vector<CMyObject>VectorObject;
CMyObject myOb;
myOb.csName = "foo";
myOb.csIindex.Format("%d", iIndex);
VectorObject.push_back(myOb);
When the user click on some column header, i like that the CSortListCtrl sorts all items and show.
Problem is that sometime i get a NULL pointer and my sort function crash!
if((GetStyle() & LVS_OWNERDATA)==0)
VERIFY( CListCtrl::SortItems( CompareFunction, reinterpret_cast<DWORD>( this ) ) );
else
{
for_each(VectorResults.begin(), VectorResults.end(), print);
sort(VectorResults.begin(), VectorResults.end(),compare_vector);
for_each(VectorResults.begin(), VectorResults.end(), print);
}
int compare_vector(const CMyObject& v1, const CMyObject& v2)
{
return lstrcmp(v1.csIndex, v2.csIndex);
}
In debug mode i can see that v2.csIndex is NULL, maybe im out of index, or what?
When i use for_each(VectorResults.begin(), VectorResults.end(), print); to see what is inside my
Vector, there is nothing strange, all infos are ok!
My question is how to use sort() ??
The idea to check if v2.csIndex is NULL dont work, because i go to CString compare funktion and
crash!
thanks for any help
termal
-- modified at 4:06 Friday 27th April, 2007
|
|
|
|
|
csIndex is of type CString (I guess) and thus cannot be NULL. Why? Because to be a NULL, it should be of a pointer type. But of course what is inside of CString (I mean its m_pData) can be NULL. So if there is no error before printing, I'm skeptical about the print method itself. Try to find out whether this method has no bugs in it.
--
=====
Arman
|
|
|
|
|
Hello,
this occurs when i try to sort my vector, and no other place!
int compare_f(CMyObject a, CMyObjectb)
{
if(0 > a.csName.Compare(b.csName))
return -1;
else if(0 < a.csName.Compare(b.csName))
return 1;
else
return 0;
}
regards
termal
|
|
|
|
|
Can anyone help me with saving a text introduced in a text button in a different file?
|
|
|
|
|
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
Anka_Ame wrote: Can anyone help me with saving a text introduced in a text button in a different file?
WTF?
|
|
|
|
|
Can you be more specific.
|
|
|
|
|
Hi
I have created db with fields as -
<br />
properties[0].wVersion = CEPROPSPEC_VERSION;<br />
properties[0].propid = MAKELONG(CEVT_LPWSTR, 0x0001);<br />
properties[0].pwszPropName = TEXT("ImagePath");<br />
properties[0].cchPropName = 9;<br />
properties[1].wVersion = CEPROPSPEC_VERSION;<br />
properties[1].propid = MAKELONG(CEVT_I4, 0x0002);<br />
properties[1].pwszPropName = TEXT("ImageStatus");<br />
properties[1].cchPropName = 11;<br />
<br />
m_pSortOrderList[0].wVersion = SORTORDERSPECEX_VERSION; <br />
m_pSortOrderList[0].wNumProps = 1;<br />
m_pSortOrderList[0].wKeyFlags = 0;<br />
m_pSortOrderList[0].wReserved = 0;<br />
m_pSortOrderList[0].rgPropID[0] = MAKELONG(CEVT_LPWSTR, 0x0001);<br />
m_pSortOrderList[0].rgdwFlags[0] = CEDB_SORT_CASEINSENSITIVE;<br />
<br />
it will sucessfully create db.
I inserted followeing element as .
<br />
record[0].propid = MAKELONG(CEVT_LPWSTR, 0x0001);<br />
record[0].val.lpwstr = TEXT("test1.bmp");<br />
<br />
record[0].propid = MAKELONG(CEVT_LPWSTR, 0x0001);<br />
record[0].val.lpwstr = TEXT("test2.bmp");<br />
<br />
record[0].propid = MAKELONG(CEVT_LPWSTR, 0x0001);<br />
record[0].val.lpwstr = TEXT("book1.bmp");<br />
<br />
record[0].propid = MAKELONG(CEVT_LPWSTR, 0x0001);<br />
record[0].val.lpwstr = TEXT("book2.bmp");<br />
when i search in db as -
<br />
CEPROPVAL seek_record[1];
::ZeroMemory(seek_record , sizeof(CEPROPVAL)*1);<br />
seek_record[0].propid = MAKELONG(CEVT_LPWSTR, 0x0001);<br />
seek_record[0].val.lpwstr = TEXT("test1.bmp");<br />
<br />
oidSeek = CeSeekDatabaseEx(m_hDBase, CEDB_SEEK_BEGINNING, 0, 0, NULL);<br />
if(oidSeek == NULL){<br />
return(false); <br />
}<br />
oidSeek = CeSeekDatabaseEx(m_hDBase, CEDB_SEEK_VALUEFIRSTEQUAL, (DWORD) <br />
seek_record, 1, NULL);<br />
It will sucessfully return oid of record.
But if search for book1 as -
seek_record[0].val.lpwstr = TEXT("book1.bmp");
then it will return zero for oidSeek,it gives me the ERROR_INVALID_PARAMETER as an error.
Does any one has any idea why this is happen.
If u have any suggestion or solution then please reply.
Thanks
-- modified at 9:51 Thursday 26th April, 2007
|
|
|
|
|
Hi,
I need some help. I'm trying to figure out the correct way to expose a "static const CString" value belonging to a class defined in an MFC DLL.
I have a class that I've encapsulated in a regular MFC DLL. The associated ".h" file looks like this:
class __declspec(dllexport) MyClass
{
public:
static const CString MY_CONST_STRING;
MyClass();
virtual ~MyClass();
void myFunc();
};
I have defined the value of MY_CONST_STRING in the class' ".cpp" file:
#include "MyClass.h"
const CString MyClass::MY_CONST_STRING = "Hello";
Although clients using the DLL can access the class (e.g., instantiate objects, call its member functions), they cannot seem to access the definition of the CString constant I have defined. When they try, they receive the following linker error:
error LNK2001: unresolved external symbol
I've defined CString constants this way in the past and referenced them without any problems, but this is the first time I've used one that was defined in an external MFC DLL class. I'm sure there's a simple answer.
Any and all help appreciated.
Thanks.
Peter
|
|
|
|
|
It is not good solution to export objects, better would be a native type (here const char*). There are same case in which object export leads to trouble: delay-load, and different version of the object (Linker-Builds).
This isnt an anwser, but a solution.
Greetings from Germany
|
|
|
|
|
A static object (or basic type) cannot be exported from a DLL. Your problem here is the static keyword, the variable will have internal linkage.
|
|
|
|