|
Hi,
I've got a static text box on my dialog, I've renamed the text box which then allows me to access its events. I've added an on click event which has automatically created an 'OnStnClicked' method and added an entry to the message map. However when I run the code the 'OnStnClicked' doesn't get called.
Do I need to add change any of the properties on the text control to allow this method to be called? (Double clicking on the text whilst in design mode takes me to the created method)
TIA,
Andy
|
|
|
|
|
Figured it out, needed to set the 'Notify' property to True.
|
|
|
|
|
You need to set the Notify property to True
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
|
|
|
|
|
If you add the SS_NOTIFY then the parent window will receive a STN_CLICKED notification (in a
WM_COMMAND message). You can set the SS_NOTIFY style in the control's property window by setting
the Notify property to true.
You can catch the message in the parent with
afx_msg void OnStaticClicked();
...
ON_CONTROL(STN_CLICKED, IDC_MYSTATIC, OnStaticClicked)
...
void CMyDialog::OnStaticClicked()
{
// do something here
}
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Hi.
Anybody know.
what's function use for convert number between binary and decimal.
|
|
|
|
|
A number is a number whether binary or decimal.
You have to define what you are trying to do before anyone will be able to help.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
|
|
|
|
|
Wes Aday wrote: A number is a number whether binary or decimal.
what about octal?
|
|
|
|
|
octal is so 1980s. I prefer base 7.
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
led mike wrote: what about octal
Well I can only count zero and not zero.... so octal is out of my league....
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
|
|
|
|
|
What is the binary type? Integer? Floating point?
By decimal, do you mean a decimal string?
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
For Example
(binary) (decimal)
00 0
01 1
10 2
11 3
What's function support this issue?
|
|
|
|
|
Ok... watching this could prove entertaining
|
|
|
|
|
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(void){
string bi = "1010"; //binary
int result= 0;
for (int i = 0; i< bi.size(); i++){
if (bi[i] == '1'){
result += pow((double)2,(double)bi.size()-i)/2;
}
}
cout << result << endl;
return 0;
}
that should work
|
|
|
|
|
string sbin("1011");<br />
char* ptr;<br />
long num = strtol( sbin.c_str(), &ptr, 2);<br />
cout << num << endl;<br />
<br />
|
|
|
|
|
oh cool function
|
|
|
|
|
I see we are having another Fish Fillet special [below]
I must horizontally challenged ... below above
Last modified: 1hr 25mins after originally posted --
|
|
|
|
|
That's two mornings in a row I smelled McD's first thing
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Hi,
I have a program, SDI, with FormView, CGreenView written in vc++6. I have created a subclass of CListCtrl named CMyListCtrl .
Now, when the user right-clicks on the listctrl, a menu pops up with options like 'edit', 'delete' etc. When the user selects 'edit' a dialog pops up and some stuff is done. The coding for the handling the right-click, calling the dialog box is done in CMyListCtrl.
After the dialog box closes, I want to call a function which is written in CGreenView the main view class.
Please can you tell me the right way of doing it?
void CMyListCtrl::OnRecordEdit()
{
if (nItem != -1)
{
CAddNew *pDlg = new CAddNew();
pDlg->type = 2;
Dlg->DoModal();
delete pDlg;
}
}
Thanks.
Fortitudine Vincimus!
|
|
|
|
|
I wouldn't try to call the containing view directly from the contained control. Rather you want to catch the EN_CHANGE or similar message that the control will send to its parent when you commit the changes to it. This will probably turn up at the parent as a WM_NOTIFY and you'll need to pull it apart from there and determine that it came from the control you're interested in and due to the cause you're looking for. Have fun
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Thank you very much for the advice.
This what I did.
Its working exacly the way I want it to.
Hope it is correct.
void CMyListCtrl::OnRecordEdit()
{
if (nItem != -1)
{
CAddNew *pDlg = new CAddNew();
pDlg->type = 2;
pDlg->DoModal();
delete pDlg;
LV_DISPINFO lvDispInfo;
lvDispInfo.hdr.hwndFrom = m_hWnd;
lvDispInfo.hdr.idFrom = IDC_FD_LIST;
lvDispInfo.hdr.code = LVN_ENDLABELEDIT;
GetParent()->GetParent()->SendMessage( WM_NOTIFY, IDC_FD_LIST,(LPARAM)&lvDispInfo);
}
else
return;
}
And in the CGreenView class :
void CGreenMView::OnEndlabeleditFdList(NMHDR* pNMHDR, LRESULT* pResult)
{
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
*pResult = 0;
}
Fortitudine Vincimus!
|
|
|
|
|
I've snagged this to open a helpfile for an MFC dialog. For now, it's OK to be just a text file, though at some point an integrated help file / CHM might be better
ShellExecute(this->m_hWnd,"open","notepad.exe","PTW Geske Analyse Help.txt","",SW_SHOW );
Problem is, I am not sure what the paths are involved. It opens notepad correctly but it is not finding the text file. I tried putting it in the same folder as the executable that's launching notepad but to no avail. How can I use a relative path so that if I distribute the program exe and the help file and state that they should be in the same folder, then notepad will correctly find the text file
t.i.a
Lee
ps
have seen ShellExecuteEx but it seemed the extra info (incl. path) refers to the path for notepad and not the target file
PS
it seems to be defaulting to desktop since thats where it saves a new file if promptedm and when I put the txt file there it does indeed open it. Perhaps I need a SetPath type instruction, but I want it to be relative to the running program and not a hard coded path.
|
|
|
|
|
Maybe check out the GetModuleFileName() API and build your full pathname from there...
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
|
ldsdbomber wrote: ShellExecute(this->m_hWnd,"open","notepad.exe","PTW Geske Analyse Help.txt","",SW_SHOW );
change to this :
::ShellExecute(NULL, _T("open"), _T("notepad.exe"), _T("PTW Geske Analyse Help.txt"), <code>NULL</code>, SW_SHOW);
it should whork, unless the PTW Geske Analyse Help.txt file is not found in the application or system path... but you can provide its full path name
|
|
|
|
|
Thanks. This is the kind of thing I keep asking about - which books will teach me how to do things the proper way. I know the _T is a unicode thing isn't it? and the :: is some kind of namespace item, so where can I get a thorough and proper grounding in "good" MFC/C++ from start to finish
|
|
|
|