|
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!
|
|
|
|
|
|
Hi,
I have a drived CArray structure defined as follows:
----------------------------------------------------
The structure MMM and the class A is defined in a main dialog (such as MyDialog.h)
Typedef struct
{
int x;
double y;
}MMM;
typedef CArray<mmm, mmm&=""> CMmmArray;
In one class called class A, I have
class A
{
....
CMmmArray m_mdata;
....
}
-----------------------------------------------------
Now, I want to access into the m_mdata from another
class (child dialog). This is MyChildDialog.h
class B
{
.....
}
How can i access and get the m_mdata in this child dialog?
Thanks in advance!
chen
|
|
|
|
|
First of all, you'd do better to use vector. Secondly, put your typedef, etc. into stdafx.h, so that the whole project knows what they are, then you'll be able to access it in the usual ways.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Thanks ! but when i put the following typedef into the
stdafx.h, it contains errors in the line:
typedef CArray<mmm, mmm&=""> CMmmArray.
Typedef struct
{
int x;
double y;
}MMM;
typedef CArray CMmmArray;
How should i change this?
chen
|
|
|
|
|
I don't know anything about CArray apart from that it sucks. You also do not need the typedef.
struct MMM
{
int x;
double y;
}
is just fine.
Try that for the struct, and it's also my opinion that you should forget the typedef, which is just confusing. I also think you should use vector, but CArray will probably work fine for what you want to do.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
I need to know the algorithm used to fill a triangle with a color gradient given the position and color of the three vertices.
I need it so I can port the GradientFill function for Windows 95.
Peter O.
|
|
|
|
|
That's usually Gouraud shading...
here's a link
and another.
|
|
|
|
|
I saw a project the other day that colored the
background of an aboutBox up to the faint blue
lines in the resource editor. How do you do that?
I can use OnCtrColor to color the background, but
it colors everything. How can I make the background
white up to the light blue lines, then a grey
edge and a border?
Please, any response any one can give me will be
greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
|
Do you have an example by chance? I just
want a simple white background color filled
in up to the faint blue lines in the dialog
resource.
Please, please, please, please, please,
please, please, please, please, please,
please, please, any response, any code you
can give me will be greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
Just FYI, the blue guidelines have no meaning outside of the resource editor. In painting code you deal with pixels.
Here's a very simple OnEraseBkgnd() to try out
BOOL CSomeWnd::OnEraseBkgnd( CDC* pDC )
{
CRect rc;
GetClientRect ( rc );
pDC->FillSolidRect ( rc, GetSysColor(COLOR_3DFACE) );
rc.DeflateRect ( 7, 7 );
pDC->FillSolidRect ( rc, RGB(255,255,255) );
return TRUE;
}
--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 want to call different views of the images through OnDraw function.from the menu.please explain me clearly.
|
|
|
|
|
eng_raju@rediffmail.com wrote:
please explain me clearly.
Well, it would help if your quesion was clear. You're writing an imaging app ? You don't know how to use a menu, or you don't know how to use OnDraw, or you don't know how to create an enum or a range of const int's ?
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Christian Graus wrote:
You don't know how to use a menu, or you don't know how to use OnDraw, or you don't know how to create an enum or a range of const int's ?
Or could it be all.
"When a friend hurts us, we should write it down in the sand, where the winds of forgiveness get in charge of erasing it away, and when something great happens, we should engrave it in the stone of the memory of the heart, where no wind can erase it" Nish on life [methinks]
"It's The Soapbox; topics are optional" Shog 9
|
|
|
|
|
Which of these three designs would you choose? #2 is a piece of cake. #1 and #3 I am exploring and have the following questions:
1.I've a bunch of options that I will append dynamically as submenus to a top level menu item. Thats doable. Then I want to keep track of which options were selected (setcheck), so that from my long list I now have a subset. Whats the smart way of going about this? I cant very well write handlers or sendmessage on the fly for every item selected in order to add its value to my subset . Like under Color, I have red, green , blue etc. The user selects say five colors. What I want from all this is merely a list of the options that were selected. These menu items dont do anything, except somehow magically add their values to the growing list. Is this reallly simple and I just cant see it?
2.Or should I spawn a modal dialog with a listcontrol with checkboxes instead.(No problem here!)
3.Actually a cool idea suggested was when Color is pressed, a hidden listcontrol shows up (obscuring stuff under it) with the possible options. When you click off it, it vanishes. This listcontrol actually exists on the CFormView but doesnt get shown until the Color button is pressed, and then its supposed to cover up a bunch of other controls also on the CFormView. I have yet to explore this avenue - I can set the listctrl invisible from the properties window easily enough. SO I just have to do something to show it when Color is pressed. MAybe theres a .visible(TRUE) type thing. Anyhoo then I have to utilise a lostfocus type event I suppose, to make it vanish.
Thank you if you've read this long post, and I'd appreciate any feedback,
ns
|
|
|
|
|
I gather you delete (this) in PostNcDestroy();
Fine .
I have a button which spawns a modeless dlg when you click, and two and three....
Since I am using the same
CModeless * pdlg = new CModeless; for each modeless dlg spawned, the old pdlg gets overwritten when another new gets called on it. So I have three modeless floating around. I click the right hand cross, and PostNcDestroy deletes "this", for any one random modeless dlg. How does this affect the other two pdlg pointers that were created when the new for those two was called?
Thanks for clearing this up,
ns
|
|
|
|
|
Unless you've got a good reason for keeping track of the spawned dialog in pdlg you actually needn't do it. As the dialogs take care of themselves by calling delete this on post-destroy time, you can safely let them live their live, and launch them this way:
new CModeless; On the other hand, if you keep your code as is, everything will work OK nevertheless --rewriting the value stored at pdlg does not affect in any manner to the dialogs previously created.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|