|
I have an dialog box that have a button in it.I want to change the caption OK button of it before DoModal() but it caused unhandled error.(Assertion failed).
CMyDlg a;
a_btn.SetWindowText("MyText");
a.DoModal();
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
What environment are you in? MS VC6?
What don't you just change it in the resource editor?
or are you trying to change it on the fly?
Later,
JoeSox
www.joeswammi.com
"Stand back! I know what I'm doing."
|
|
|
|
|
JoeSox wrote:
What environment are you in? MS VC6?
VC7.
JoeSox wrote:
What don't you just change it in the resource editor?
or are you trying to change it on the fly?
I want to do it in runtime.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Nevermind my other post, I don't think SetWindowText is what you need to call.
try
The SetDlgItemText function sets the title or text of a control in a dialog box.
BOOL SetDlgItemText(
HWND hDlg, // handle of dialog box
int nIDDlgItem, // identifier of control
LPCTSTR lpString // text to set
);
see the mfc help, for more info
Later,
JoeSox
www.joeswammi.com
"Stand back! I know what I'm doing."
|
|
|
|
|
aDlg.SetDlgItemText(IDOK,"sometext");
No change.Still the same problem.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
The dialog and its controls aren't created until DoModal() is called. The correct place to set the button text is OnInitDialog() .
--Mike--
When 900 years old you reach, look as good you will not. Hmm.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Oh,thanks.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
hi,
try doing this..
oninitdialog write the bit of code like
a_btn.SetWindowText("MyText");
before your dialog loads it will set the caption to what you want. not before domodal() because your dialog doesn't exist physically where you write domodal(). I guess that's why you are facing the problem. try doing this i guess this should work..
cheers..
Himanshu
|
|
|
|
|
hi all,
i am stuck..can anyone help... I want to run an exe on click of a button..can i do so..If yes can anyone guide me...please..
Thanx zillions in advance..
Himanshu
|
|
|
|
|
you can use ShellExecute function:
ShellExecute(hwnd,"open","C:\file_path",NULL,NULL,0)
the last three arguments specify working directory , parameters ...etc.
|
|
|
|
|
Hie
You can use WinExec("toto.exe",SW_SHOW);
Serge
|
|
|
|
|
I'm having troubles modifing the rclBounds in the ENHMETAHEADER structure. I would like to do this in memory and once done use the CopyEnhMetaFile to save it to disk.
|
|
|
|
|
This function seems simple enough, and does everything the SDK documentation indicates is necessary to change the selection state of an item in a list view control. After observing that it wasn't working, I added the assert in the last line of the function and sure enough, the assert fires. This makes no sense whatsoever.... Help please!
void
ListViewHelper_t::DeselectItem(int32 index)
{
LVITEM item_info;
item_info.iSubItem = 0;
item_info.mask = LVIF_STATE;
item_info.state = 0;
item_info.stateMask = LVIS_SELECTED;
item_info.iItem = index;
SendMessage( (HWND)HelperWindowHandle(), LVM_SETITEMSTATE, index, (LPARAM)&item_info );
assert( !IsItemSelected(index) );
}
bool
ListViewHelper_t::IsItemSelected(int32 index) const
{
return ( (SendMessage( (HWND)HelperWindowHandle(), LVM_GETITEMSTATE, index, LVIS_SELECTED ) & LVIS_SELECTED) == LVIS_SELECTED );
}
|
|
|
|
|
Rule #1 of list and tree ctrl structs: always init them to zero. The mask member is supposed to make that unnecessary, however I've seen the controls misbehave when the supposedly unused members weren't 0.
LVITEM item_info <font color=red>= {0}</font>; Give that a try.
--Mike--
When 900 years old you reach, look as good you will not. Hmm.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
That did it. Thanks a bunch!
|
|
|
|
|
How do you convert a piece of DirectX SDK coding to an ActiveX Control? I tried to convert a piece of program(DirectX SDK coding) to an ActiveX, the source code compiled successfully, but when i tried to use the ActiveX control it gives a message "FAILED TO CREATE THE COMPONENT". I couldnt debug the code. Help me to Solve the problem.
Make the POSSIBLE, HAPPEN - immasara
|
|
|
|
|
I'd like to save a list of files into a certain directory. I used Spy++ and saw that apps use SysTreeView32. Ok, but searching for it in .NET I found nothing. Then I searched for it on Google and found that it's actually a combination of CTreeView and CTreeCtrl. Yet even with that, I don't know how to add all the directories in the system.
|
|
|
|
|
if you are working on MFC try this link..
http://rossm.net/Electronics/Computers/Software/C++/MFC.htm#DTree
maybe you can get some help..
cheers
Himanshu
|
|
|
|
|
Can anyone Help
I am having problems adding a filter to my STL List the problem is in the function
AddFilter.
The char string FilterName is not being added correctly in the statement mfilter.push_back(FilterName);
by replacing the variable FilterName for literals there is no problem.
When debuging the previus is always the current FilterName it appears the reference the same location.
The code below shows what i have implemented please take a look and let me know where I mest up.
Any Help would be appreciated
Thanks
//----------------------------------------------------------------------------
// Mesage handler for Filter box.
//----------------------------------------------------------------------------
LRESULT CALLBACK Filter(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
HWND hwndList;
int iSel;
int cIndex;
int success;
switch (message)
{
case WM_INITDIALOG:
hwndList = GetDlgItem(hDlg, IDC_FILTERLIST);
if(nFilters > 0)
{
char tmp[MAX_FILTER_LENGTH];
for(FilterIterator = mfilter.begin();
FilterIterator != mfilter.end();
FilterIterator++)
{
strcpy(tmp, *FilterIterator);
iSel = (INT)SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)tmp);
SendMessage(hwndList, IDC_FILTERLIST, iSel, (LPARAM)tmp);
}
}
break;
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
success = FALSE;
switch (wmId)
{
case IDOK:
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
break;
case IDCANCEL:
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
break;
case IDC_ADD_STRING:
char tmpfilter[MAX_FILTER_LENGTH];
GetDlgItemText(hDlg, IDC_NEWFILTER, (LPTSTR)tmpfilter, strlen(tmpfilter));
success = AddFilter(tmpfilter);
if (success == TRUE)
{
hwndList = GetDlgItem(hDlg, IDC_FILTERLIST);
iSel = (INT)SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)tmpfilter);
SendMessage(hwndList, IDC_FILTERLIST, iSel, (LPARAM)tmpfilter);
SetDlgItemText(hDlg, IDC_NEWFILTER, "");
}
break;
case IDC_FILTERLIST:
if (wmEvent == LBN_DBLCLK)
{
MessageBox(hDlg, "ListBox", "LISTBOX", MB_OK);
hwndList = GetDlgItem(hDlg, IDC_FILTERLIST);
cIndex = SendMessage(hwndList, LB_GETCURSEL, 0, 0);
FilterIterator = mfilter.begin();
advance(FilterIterator, cIndex);
mfilter.remove(*FilterIterator);
SendMessage(hwndList, LB_DELETESTRING, cIndex, 0);
}
break;
}
}
return FALSE;
}
//----------------------------------------------------------------------------
// Function AddFilter
//----------------------------------------------------------------------------
BOOL AddFilter(char* FilterName)
{
bool RetCode;
// abort if too many filters
if( nFilters >= MAX_FILTERS )
{
RetCode = FALSE;
}
else
{
int fSize = strlen(FilterName);
if( fSize >= 1)
{
// This is the code which fails
mfilter.push_back(FilterName);
// This section proves the data is written to the list and is diplayed correctly when the
//filter dialog is opened calling Filter(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
if(nFilters == 0)
mfilter.push_back("One");
else if(nFilters == 1)
mfilter.push_back("Two");
else if(nFilters == 2)
mfilter.push_back("Three");
else
mfilter.push_back("Else");
//
nFilters++;
RetCode = TRUE;
}
}
return RetCode;
}
|
|
|
|
|
Are you storing raw pointers in the list? It looks like you're storing pointers instead of full copies of the strings. This would explain your problem and also explain why using statically declared strings works.
I suggest you store a string class in your list. Preferably one that is reference counted, if you're doing things like sorting the list (VC++ _bstr_t class is ref counted).
E.g.
std::list<String> mfilter
|
|
|
|
|
Thanks I will look for info on the _bstr_t class, this is what I want to acheive.
I have declared the list :-
typedef list<char*> FILTERLIST;
I simply require a list capable of allowing addition and deletion of strings no sorting is required. The dialog box allows the user add and remove strings from the list. The strings in the list then used with the strstr() function one I had problems using cstring with strstr() and other variables such as static char buf[MAX_LINE_LENGTH];
// test filter option
if(prefs.filter && nFilters > 0)
{
bool found = FALSE;
int Loop = 0;
while(Loop < nFilters && found == FALSE)
{
char tmp[MAX_FILTER_LENGTH];
FilterIterator = mfilter.begin();
advance(FilterIterator, Loop);
strcpy(tmp, *FilterIterator);
if(FALSE != strstr(buf, tmp))
found = TRUE;
Loop++;
}
// display message if filter not found
if(found == FALSE)
update = AddLine( i, buf );
}
else
{
// display message
update = AddLine( i, buf );
}
|
|
|
|
|
In my MFC dialog program, I have a dialog box with a CRichEditCtrl on it using the dialog editor. I want to dynamically create a CRichEditCtrl just like that, but it's not looking quite right:
static (using dialog editor): http://igx89.digitalrice.com/good.jpg[^]
static code:
CONTROL "",IDC_EDIT1,"RichEdit20A",ES_MULTILINE | ES_AUTOVSCROLL | <br />
ES_READONLY | NOT WS_VISIBLE | WS_BORDER | WS_VSCROLL | <br />
WS_TABSTOP,7,18,303,238<br />
dynamic: http://igx89.digitalrice.com/bad.jpg[^]
Dynamic code:
ChatList->Create(ES_MULTILINE | ES_READONLY | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_TABSTOP,rect,this,WM_USER+600);<br />
What am I doing wrong? I tried using GetStyle() to get the style directly from the static control and put it in the dynamic, but then the control didn't have a border!
|
|
|
|
|
I want to replace it by one of my own
|
|
|
|
|
The simplest way to do this is to disable the built-in scrollbar on the list box, and then place your own adjacent to the list box. I'm not sure if even using ownerdraw you could actually replace the built-in scrollbar.
Software Zen: delete this;
|
|
|
|
|
I've thought that too, but if i do, i'll have to map the mouse and key events by my own, i only want to replace the classic scroolbar by one of my own, withou mapping the events, is there another way?
|
|
|
|
|