|
Sounds to me like the sort of problem that is fixed by a rebuild all. By changing the affected files, you forced a build on them. When that sort of error happens to me, the first thing I do is clean/rebuild all, then spend the build time thinking about what else it might be.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Thanks, I'll try that next time.
-Raffi
|
|
|
|
|
I'm a beginner programmer with no formal training so forgive me for asking such a basic question.
I'm having trouble passing information between dialogs. For instance, if I pop up a dialog and have an edit box that accepts a piece of data, when the edit box closes i'd like to get that piece of data to the main dialog.
My testbed for figuring out how to do this has been a simple MFC dialog app with an about box. I have added an edit box to the about dialog, and when I click 'ok' i'd like the main dialog to be able to access that variable.
I can easily solve the problem with a global variable but from what little studying i've done I know that it's "bad programming" and sloppy. I don't want to kick off my programming education with bad techniques so can someone explain the proper way to do this? An explanation in terms of working with the about box scenario described above would be most helpful.
Thank you.
|
|
|
|
|
Otyug wrote:
so forgive me for asking such a basic question.
Remember, the person who answers probably asked it once as well
I'm glad you've researched enough to understand that globals are a bad idea. If you're creating a modal dialog, the answer is a variable in your dialog class. The edit box is a window and therefore gone when the dialog closes, but if you store the contents of the edit box into a string, that will be accessible after it closes. So if you define a string called m_sEdit in the dialog, and set it to equal GetWindowText on the edit box in OnOK, then
CMyDlg dlg;
if (IDOK == dlg.DoModal())
{
AfxMessageBox(dlg.m_sEdit;
}
Strictly speaking, the variable should be private and a get method exposed, but in a case like this I think that is redundant. You can't set it to anything meaningful either before or after the modal loop in any case.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
MS used to sell a cross-platform compiler for the MAC that allowed MFC apps to be compiled for the MacIntosh platform. Last version I think was Visual C++ 4.2 (or 4.0?). Has anyone ported a MFC app to Mac OS 9 or X? Is anyone still using VC++ 4.X for Mac? My app is fairly simple, although it does rely on the IE IWebBrowser2 component for some functionality.
I would love to hear anyone's (recent) experiences of trying to get an MFC app ported to the Mac, which seems to be making a comeback of sorts...
Thanks!
Harlan
|
|
|
|
|
The last time I did this was in 1997-98 using the VC Cross compiler. Not sure which version of Mac OS but it certainly wasn't OS 9 or X. It wasn't easy as there are lots of UI difference that made things difficult.
I don't think MS support the cross-platform compiler anymore. Your best bet is to look at something like CodeWarrior but don't expect MFC compatability.
Michael
Look, try and use your intelligence, man, even if you are a politician. - The Doctor
|
|
|
|
|
hello i am a biginner VC++ programmer and i am having problems in adding the icon of my applications in system tray ..how can i do it...can u please help me.
nauman ghazi
|
|
|
|
|
You can either use the Shell_NotifyIcon API call or you can use Chris Maunder's class! The first one is easier as it involves just that one call. The 2nd one is a lot more powerful, because Chris has thrown just about every feature you can think of into his little class.
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
What I mean by this subject is that I need to be able to open a text file, read it's information in, convert it to raw binary information ( ex. "this is a test" = 10110110 ) and then save that information out to a new file. I am unsure of the code ro do the actuall ASCII to Binary Conversion. If anyone has code to do this under straight WIN32 API I would be very grateful.
It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now...
[Shog9 on Kid Programmers]
|
|
|
|
|
Never heard of a Win32 API that will do what you want. You'll have to write the function yourself by converting each character.
|
|
|
|
|
I know there isn't a function in win32 API that can do this transparently, which is why I was asking here about how to do the actual CONVERSION as I don't know how to do it.
It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now...
[Shog9 on Kid Programmers]
|
|
|
|
|
There are at least two ways I know of to convert a number to its binary value, like the windows calculator does.
(1) Set up a bit structure and access each of its members just like any other structure.
typedef union
{
struct bits
{
unsigned short bit1:1;
unsigned short bit2:1;
// etc.
} bits;
unsigned short theNumber;
}BITS;
BITS b.theNumber = 365;
int bit1 = b.bits.bit1;
(2) A much more efficient way is to compute the bit pattern using the >> operator. If you look at the assembly code produced by the compiler from the method shown above, you will see that it actually uses the right shift operator to get the value out of the structure.
int x = 365;
for(int i = 1; i <= 16; i++)
{
int n = (x >> i) & 1;
printf("%d\n", n);
}
|
|
|
|
|
Have a look at std::bitset and its to_string.
|
|
|
|
|
would I be able to take a string using one of the above methods and use this kind of progression on it? See Below:
string > individual characters > binary value > string?
the reason why i want to get a string of binary values is so that I can run an rle algorithem on the resultant string and compress it down REALLY tight. I figure I'm more likely to get a really long run with rle if I'm dealing with either a 1 or 0 bit value as opposed to hex, octal, etc.
It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now...
[Shog9 on Kid Programmers]
|
|
|
|
|
John Aldrich wrote:
the reason why i want to get a string of binary values is so that I can run an rle algorithem on the resultant string and compress it down REALLY tight.
And you expect to get a "REALLY tight" compression using this? Make it easy on yourself and have a look at zlib or LZO.
|
|
|
|
|
Ok I know this is kinda simple, but why doesn't this produce a linefeed (or carrage return) ?
CFile cFoo;
cFoo.Open("bar.txt",CFile::modeCreate | CFile::modeWrite );
{
cFoo.Write(_T("TEST\n"), 5);
cFoo.Write(_T("TEST2\n"),6);
cFoo.Write("TEST3\n",6);
}
cFoo.Close();
Thanks
Regardz
Colin J Davies
Sonork ID 100.9197:Colin
More about me
|
|
|
|
|
Maybe you need to add the \r carrage return?
cFoo.Write(_T("TEST\n\r"), 6);
Does that work??
|
|
|
|
|
Hey Colin
I just noticed when you open the file the option CFile::typeText is not specified.
MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_cfile.3a3a.write.asp
Also:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_cfile.3a3a.cfile.asp
"CFile::typeText Sets text mode with special processing for carriage return–linefeed pairs (used in derived classes only)."
You should get your carrage returns then. Also carrage return\linefeed is counted as one character. Hope I helped.
|
|
|
|
|
|
Because a "newline" in DOS/Windows is "\r\n" not just "\n". FYI, if you use CStdioFile::WriteString(), it converts "\n" to "\r\n" on the fly.
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
|
I have
void CMainFrame::SaveOptions2()
{
CRect rc2;
GetWindowRect(&rc2);
HKEY key;
DWORD size, type, disposition;
if (RegOpenKeyEx( HKEY_CURRENT_USER,APPLICATION_KEY,0,
KEY_WRITE,&key)!=ERROR_SUCCESS)
{
RegCreateKeyEx(HKEY_CURRENT_USER,APPLICATION_KEY,0,"",
REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,
&key,&disposition);
}
// int
type = REG_DWORD;
size = 4;
m_height = rc2.Height();
RegSetValueEx( key,OPTIONHEIGHT_KEY,0,type,(LPBYTE)&m_height,size );
type = REG_DWORD;
size = 4;
m_width = rc2.Width();
RegSetValueEx( key,OPTIONWIDTH_KEY,0,type,(LPBYTE)&m_width,size );
m_top = (int)rc2.top; //because .top is long
RegSetValueEx( key,OPTIONTOP_KEY,0,type,(LPBYTE)&m_top,size );
// m_lft = (int)rc2.left;
// RegSetValueEx( key,OPTIONLEFT_KEY,0,type,(LPBYTE)&m_left,size );
If I uncomment the last two lines, biiig crash! m_left is just declared a simple int, just like the rest.
?????
Appreciate your response,
ns
|
|
|
|
|
|
Nope, Its not a typo! I found that the trouble is I am not allowe dto add any kind of member variable (private or public - DWORD, CString, int I tried). as soon as I add one, it crashes. Remove the variable and alls well. Creating a local variable is fine. I dont understand this......any ideas? Thank you,
ns
|
|
|
|
|
Two things:
For some reason I had two .h files of the same class in the project even though the workspace didnt indicate it. Found it out by accident.
Second: it was still being flaky so I did a rebuildALL - now it works like a charm!
|
|
|
|