|
...I'm thinking you don't really know the MFC framework?
|
|
|
|
|
I'am a green hand.
|
|
|
|
|
see what ozer wrote above... i think i misunderstood your question, i thought you were trying to access cmainframe from cwinapp, a trivial operation, but you're really trying to access dgDlg (who is owned the cwinapp) from the cmainframe... that's not as trivial (but almost... )
Happy coding!
|
|
|
|
|
Hi!
I've to customize the Product Name property of Visual Studio Deployment Project.i.e I don't want to Enter directly into the property box. Instead, I've kept it in an XML file. How to assign the property from C++ code? Also, I want to create an Uninstaller for this Setup. I don't know how to do this. Can any one help?
|
|
|
|
|
Usually the properties for studio projects are stored in the resource file of the project (at least for C++ they are, I'd imagine there's something similar in a Deployment Project), look to see if you can find and edit that (by hand, programatically, whatever, at that point its just text in a file).
Don't know about installer/uninstaller in Studio, I use InstallShield.
|
|
|
|
|
oh wait... you want to make it dynamic at run-time? ...haven't used that feature enough to recommend something...
|
|
|
|
|
Albert Holguin wrote: you want to make it dynamic at run-time?
Not at run-time. But It has to change according to the XML tag value.
|
|
|
|
|
if you're ok with re-compiling... most of the installers are script based, so you should be able to edit properties programatically then rebuild the installer. Most of my experience is with InstallShield though so I can't help with exactly how to do it. Sorry!
|
|
|
|
|
Hello All,
My programmer is saying me that reverse search (meaning which up and down search in our application,which is developed in VC++) is not possible if we use CRichEditCtrl class.. Is he right?? I feel it should be possible, though am not VC++ expert... I agree to the fact that i know very little in VC++.
Please guide us whether it is possible or not. If possible,can someone post a sample code?
Thanks,
Rakesh
|
|
|
|
|
I think its easily possible since there is FindText fucntion on CRichEditCtrl. Searching can be implemented in any direction using the CHARRANGE members of FINDTEXTEX Structure logically. But get conveyed from the programmer why he says so.
|
|
|
|
|
I don't think the use of CRichEditCtrl would have any bearing on it, but you would need to give more detail about the application and why the programmer believes it is not possible.
[edit]According to the MSDN documentation[^] you can set options in the Findtext() function to search forwards or backwards.[/edit]
I must get a clever new signature for 2011.
|
|
|
|
|
Hi. I want to be able to extract all the array associated in a listbox-items, but i am failing to find a thing to put in my for loop. the LB_GETCURSEL doesnt seem to be the correct one here... can someone point me the message I should be using?
HWND handle_List = GetDlgItem(hwnd, IDC_LIST_COMPARE);
count = SendMessage(handle_List, LB_GETCOUNT, 0, 0);
for (i =0; i<count; i++)
{
int index = SendMessage(handle_List, LB_GETCURSEL, 0, 0);
int data = SendMessage(handle_List, LB_GETITEMDATA, (WPARAM)index, 0);
MessageBox (hwnd, (char *)data, "The stored data is", MB_OK);
}
break;
this is the link for MSDN listbox thing. http://msdn.microsoft.com/en-us/library/bb775146%28v=vs.85%29.aspx[^]
can someone please point me which message i should be using? thank you very much.
btw i am sure the information/array is associated to the object in the listbox
|
|
|
|
|
for (i =0; i<count; i++)
{
int data = SendMessage(handle_List, LB_GETITEMDATA, (WPARAM)i, 0);
MessageBox (hwnd, (char *)data, "The stored data is", MB_OK);
}
|
|
|
|
|
You are using the wrong index value and the wrong message(s) see here[^]. Try the following
char textBuf[64];
for (i =0; i<count; i++)
{
SendMessage(handle_List, LB_GETTEXT , (WPARAM)i, (LPARAM)textBuf);
MessageBox (hwnd, textBuf, "The stored data is", MB_OK);
}
[edit]Also, you cannot cast an int to a char* and expect it to display a sensible value.[/edit]
I must get a clever new signature for 2011.
|
|
|
|
|
what is a char* ? ...its an integer pointer to a string, so it really depends on the other code whether it displays sensible data...
|
|
|
|
|
If you read my comment: I said that you cannot cast an int , which is a pure binary number, to a char* , which is a pointer to an array of characters, and expect to get sensible output.
[edit]Hence the OP's comment:
[/edit]
I must get a clever new signature for 2011.
|
|
|
|
|
that's not true... a char* is an integer... if the int holds the location of the initial character of a string (and the array is null terminated) it can be cast that way.
|
|
|
|
|
Is your real name SAKryukov?
I must get a clever new signature for 2011.
|
|
|
|
|
...i don't mean it in a mean way, more of a matter of fact sort of way...
|
|
|
|
|
Sorry LB_GETTEXT is not what I want. I want the data/string associated with the item. GETTEXT shows me the text for the string that is already displaying in the listbox.
|
|
|
|
|
OK just replace the LB_GETTEXT like this:
int data = SendMessage(handle_List, LB_GETITEMDATA, (WPARAM)i, 0);
However you do not say what data you are expecting to get returned from the ListBox . In your original sample you cast the returned value to a char* and then complain you always get "?" printed out, so I am assuming it is not a pointer to a character array. What value do you store in the itemdata when you create the ListBox ?
I must get a clever new signature for 2011.
|
|
|
|
|
i stored a TCHAR File_name in the listbox. here is the code for how i stored it.
int index = SendDlgItemMessage(hwnd, IDC_LIST_COMPARE, LB_ADDSTRING, 0, (LPARAM)str);
SendDlgItemMessage(hwnd, IDC_LIST_COMPARE, LB_SETITEMDATA, (WPARAM)index, (LPARAM)File_name);
here is the check I have after I add the string in just to make sure.
HWND hList = GetDlgItem(hwnd, IDC_LIST_COMPARE);
int data = SendMessage(hList, LB_GETITEMDATA, (WPARAM)index, 0);
MessageBox (hwnd, (char *)data, "The stored data for the newly selected item is...", MB_OK);
here the message box displays the string fine. I am pretty much using the exact same code as u have suggested, but i just cannot get it to work in the for loop for some stupid reason -_-;;
|
|
|
|
|
A couple of suggestions:
In your data retrieval loop your code might be a bit clearer if you write it as:
char* string = (char*)SendMessage(hList, LB_GETITEMDATA, (WPARAM)i, 0);
Also check that the returned pointer string still points to a valid address. When you add these data items to your list box, if they are pointers to local memory you need to ensure that they are not destroyed. Your code above does not make it clear exactly how they are created, and whether they are permanent.
I must get a clever new signature for 2011.
|
|
|
|
|
LOL still doesnt work. this problem is driving me insane... I need to link the filename with the item in the listbox >.<. why does it work on every single example i see on the web!
here is the full code. Please tell me if I made any mistake
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case ID_CMP_LOADFILE:
{
OPENFILENAME ofn;
TCHAR File_name[MAX_PATH];
int index = SendDlgItemMessage(hwnd, IDC_LIST_COMPARE, LB_ADDSTRING, 0, (LPARAM)str);
sprintf(File_name, "1");
SendDlgItemMessage(hwnd, IDC_LIST_COMPARE, LB_SETITEMDATA, (WPARAM)index, (LPARAM)File_name);
HWND hList = GetDlgItem(hwnd, IDC_LIST_COMPARE);
int data = SendMessage(hList, LB_GETITEMDATA, (WPARAM)index, 0);
MessageBox (hwnd, (char *)data, "The stored data for the newly selected item is...", MB_OK);
fclose(file_opened);
}
break;
}
case ID_CMP_COMPARE:
{
int count;
int i;
HWND handle_list = GetDlgItem(hwnd, IDC_LIST_COMPARE);
count = SendMessage(handle_list, LB_GETCOUNT, 0, 0);
for (i =0; i<count; i++)
{
TCHAR* data = SendMessage(handle_list, LB_GETITEMDATA, (WPARAM)i, 0);
MessageBox (hwnd, data, "The stored data for the newly selected item is...", MB_OK);
}
break;
}
thank you all soo much.. i really need to crack this..
|
|
|
|
|
As I said before, you need to be sure that your data fields are pointing at static memory blocks. You have the following line(s) in your code:
TCHAR File_name[MAX_PATH];
int index = SendDlgItemMessage(hwnd, IDC_LIST_COMPARE, LB_ADDSTRING, 0, (LPARAM)str);
sprintf(File_name, "1");
SendDlgItemMessage(hwnd, IDC_LIST_COMPARE, LB_SETITEMDATA, (WPARAM)index, (LPARAM)File_name);
However, as soon as you leave this function the variable File_name will be destroyed (because it is on the stack) and your pointer is no longer valid.
You need to do something like:
PTSTR pFile_name;
int index = SendDlgItemMessage(hwnd, IDC_LIST_COMPARE, LB_ADDSTRING, 0, (LPARAM)str);
pFile_name = new TCHAR[the length of the filename + 1];
SendDlgItemMessage(hwnd, IDC_LIST_COMPARE, LB_SETITEMDATA, (WPARAM)index, (LPARAM)pFile_name);
now when you leave this function your filename memory buffer will not be destroyed. You should also remember to delete[] all these memory blocks when you destroy your listbox.
I must get a clever new signature for 2011.
|
|
|
|
|