|
Have you tried making the doThatThing() member function static ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hah! As simple as that. Worked perfectly.
Thanks a lot
|
|
|
|
|
I'm not really sure what you're trying to do, but it may be an ambiguity between ::doThatThing() and programApp::doThatThing() so you may have to explicitly declare the parameter as either ::doThatThing() or programApp::doThatThing() depending on where it is called.
|
|
|
|
|
I have seen at least one commercial product (VisualTest) that has a horizontal splitter window with a title. That is, the top gripper bar is wider than normal, and has text in it that describes the contents of the window below. A screen shot is available at:
http://www.magicdave.com/private/browse/vt.jpg
I can sort of simulate that if the window contains a ListView by setting the ListCtrl to REPORT style and adding one column heading with the text, but that leaves you with that annoying column sizing thing in the header, which I find unaesthetic. Further, you're out of luck entirely if the window contains a TreeCtrl--and the window I'm making does.
I have tried every solutuion I can think of, including attaching a custom CHeaderCtrl, but nothing seems to work.
Any suggestions?
|
|
|
|
|
looks to me like an edit box with static text label at the top of it.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
>looks to me like an edit box with
>static text label at the top of it.
Ah, that's another wrinkle I should have mentioned. This would indeed be fairly easy to do in a dialog-based app, but my app is SDI.
I'm thinking there must be some way of subclassing a splitter window to give it a title bar, but I haven't been able to find it.
|
|
|
|
|
Hi
I'm having some problems storing some values. Here is it:
I have a class with is derived from CObject. It just stores Variables !
<br />
CMyStoreClass : public CObject<br />
{<br />
CString m_strName;<br />
<br />
CUIntArray m_arFirstArray;<br />
CUIntArray m_arSecondArray;<br />
[...].br />
CUIntArray m_arSixthArray;<br />
}<br />
Then in my Dialog class I have a variable which shall store the CMyStoreClass Instances.
<br />
CPtrList m_Rules;<br />
To Add a Instance of CMyStoreClass:
<br />
CMyStoreClass store;<br />
store.m_strName = "Test";<br />
store.m_arFirstArray = 5;<br />
store.m_arSecondArray = 6;<br />
[...].br />
if(m_Rules.IsEmpty())<br />
m_Rules.AddHead(&store);<br />
else<br />
m_Rules.AddTail(&store);<br />
Everthing still works fine but now if i want to access the CMyStoreClass Objects again:
<br />
for(POSITION pos = m_Rules.GetHeadPosition();pos != NULL; )<br />
{<br />
CMyStoreClass* pStore = (CMyStoreClass*) m_Rules.GetNext(pos);<br />
ASSERT(pStore);<br />
if(pStore->m_strName != "Test") continue;<br />
}<br />
when my programm executes this lines it breaks and "strcmp.asm" opens and i get to "dodwords:".
I have no clue what's wrong. Anyone ? Any clue ?
MFG
RedDragon2kx
Unix and C are the ultimate computer viruses.
|
|
|
|
|
Have you stepped into CString 's != operator to see what is going on?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I gonna try this, but if i try:
<br />
MessageBox(pStore->m_strName);<br />
it fails, szText is marked as <badptr> in Debugger Window. It says:
CXX0030: Error: expression cannot be evaluated char
Unix and C are the ultimate computer viruses.
|
|
|
|
|
RedDragon2k wrote:
it fails,
Which means what?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
pStore->m_strName {0x00000000 <bad ptr="">}
- ATL::CSimpleStringT<char> {0x00000000 <bad ptr="">} ATL::CSimpleStringT<char>
- m_pszData 0x00000000 <bad ptr=""> char *
CXX0030: Error: expression cannot be evaluated char
Unix and C are the ultimate computer viruses.
|
|
|
|
|
I'm wondering if the ATL forum would be of any help.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I gonna post there, too. Thx for your help
Unix and C are the ultimate computer viruses.
|
|
|
|
|
I think I see what might be ailing you. Try this:
CMyStoreClass *store = new CMyStoreClass;
store->m_strName = "Test";
store->m_arFirstArray = 5;
store->m_arSecondArray = 6;
[...].if(m_Rules.IsEmpty())
m_Rules.AddHead(store);
else
m_Rules.AddTail(store); BTW, you can use AddTail() exclusively rather than calling IsEmpty() and AddHead() .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thx man, that helped.
Unix and C are the ultimate computer viruses.
Visit me: www.programming.info.ms
|
|
|
|
|
I'm trying to convert a Ctring I read from an editbox into a float. This is the code I've got so far;
CString val, txtEdit;<br />
float boxval = 0.2f;<br />
<br />
GetDlgItemText(IDC_EDITBOX,txtEdit);<br />
char *txt = (char *) (LPCTSTR) txtEdit; <br />
<br />
<br />
sscanf(txt, "%f", &boxval);<br />
val.Format(_T("%f"), boxval);<br />
AfxMessageBox(val);
Unfotunately it does not return the right float. It does return a float but it is truncated to its integer value. I.e. if I enter 2.3 it returns 2.00.
Could anyone help me here? What am I doing wrong?
What's the best way to convert a string into a float?
Thanks!
|
|
|
|
|
How about:
GetDlgItemText(IDC_EDITBOX, txtEdit);
double d = atof(txtEdit);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks, I had tried that too but have the exact same problem!
I should prob add that it works ok with text in define in the code but not with text I read from an edit box...
Really don't understand what I'm doing wrong???
|
|
|
|
|
What is the value of txtEdit after the call to GetDlgItemText() ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
When I display it in a messagebox its value is the decimal value read from the edit box.
|
|
|
|
|
Unless there is something else going on that is not being shown, the code snippet I provided will work.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Actually I've only just realised that only the first digit is being converted. I.e. if I enter 2.3 I get 2.00 but if I enter 14.6 I get 1.00.
I must do something really wrong somewhere but I can't see where!
Thanks for your help!
|
|
|
|
|
Something's definitely amiss here. If you don't make the call to GetDlgItemText but, instead, just set txtEdit to "2.334" (for example), boxval ends up being 2.334 (or whatever you ste in txtEdit ). This works just fine...tested it m'self, I did.
So something's not right, and it's definitely something to do with the conditions under which GetDlgItemText is called. Maybe you're only responding to single keystrokes in the edit box, I'm not sure.
Some things to try testing:
* GetDlgItemText returns the number of characters copied. Store this returned value to an int and make sure it's returning the right number of characters.
* sscanf returns the number of arguments extracted from the string. So if your sscanf() isn't returning '1', then something's wrong.
Bob Ciora
|
|
|
|
|
First thanks for the help! Much appreciated!
Here's my exact code now;
void CmySpinButtonCtrl::OnDeltapos(NMHDR* pNMHDR, LRESULT* pResult) <br />
{<br />
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;<br />
<br />
<br />
CString tmp, txtEdit="82.45";<br />
float boxval;<br />
<br />
char *txt = (char *) (LPCTSTR) txtEdit; <br />
sscanf(txt, "%f", &boxval);<br />
double d = atof(txt); <br />
<br />
tmp.Format(_T("atof is %f"), d);<br />
AfxMessageBox(tmp);<br />
tmp.Format(_T("sscanf is %f"), boxval);<br />
AfxMessageBox(tmp);<br />
<br />
<br />
*pResult = 0;<br />
}
Both Message boxes display the same value 8.0000.
This function is being called every time the spinner is clicked on.
I'm lost now! What am I doing wrong?
|
|
|
|
|
Try putting a breakpoint at the start of the function, then single step through it (with F10). Use your Watch window to watch the values of tmp , txtEdit , boxval , and d as each line is executed. Validate the values at each step, and make sure you see the following:
(code) (output)
CString tmp, txtEdit="82.45";
float boxval;
char *txt = (char *)(LPCTSTR)txtEdit;
sscanf(txt, "%f", &boxval);
double d = atof(txt);
tmp.Format(_T("atof is %f", d);
tmp.Format(_T("sscanf is %f", boxval);
Definitely a stumper, but it's definitely worth single stepping.
As a side note on programming practice, you should do the following:
const char * txt = (LPCTSTR)txtEdit; instead of your original char * txt = (char *)(LPCTSTR)txtEdit; . You may run into unintended consequences if you force a const to a non-const . It's not hurting you here, but it could bite you in bad places. I'm curious to know if you get a compiler warning from your original statement.
Bob Ciora
|
|
|
|