|
BigDaddyDrew wrote:
I'm getting the linker error for unresolved external symbols
which symbols??
-c
Be very, very careful what you put into that head, because you will never, ever get it out. --Thomas Cardinal Wolsey
|
|
|
|
|
The two static variables:
job.obj : error LNK2001: unresolved external symbol "private: static int Job::machPerJob" (?machPerJob@Job@@0HA)
job.obj : error LNK2001: unresolved external symbol "private: static int Job::numOfMach" (?numOfMach@Job@@0HA)
Andrew
|
|
|
|
|
Ooop, nevermind, I fixed it. Forgot to declard them outside of the class.
|
|
|
|
|
|
I think thats what its called. Anyway, I got the open file dialog working. Since I am a lazy bumb I have decided to make the program compatible with all files (that have text). However, I do not know how I would wright the text from the file into the edit box. Could someone help me here? I mainly want it so that it can open a .html or .htm, .c or .cpp, .h, .txt files. How would I do this I have no idea. So could some one either tell me how (prefereable with some example code) or tell me a URL that might help me.
Thanks,
orcblood
|
|
|
|
|
If I understand you right, you want to read text from file and load it into and Edit control.
If it is so then this is sample code for both reading both ANSI and UNICODE text files:
<code>
CFile f;
if(f.open("FILENAME.TXT, CFile::modeRead))
{
DWORD dwFLen = f.GetLength();
//this short will be used to get the file header
USHORT usHeader;
f.Read(&usHeader, sizeof(USHORT));
//UNICODE text files starts with value 0xFEFF
if(usHeader == 0xFEFF)
{
//we are going to load the text into a character array
wchar_t * filetxt;
//allocate a charaters array one for null terminator
filetxt = new wchar_t[dwFLen + 1];
//clear the filetxt array
memset(filetxt, 0, sizeof(wchar_t) * (dwFLen + 1));
f.Read(filetxt, dwFLen);
//use API function rather than MFC to be able
//to read UNICODE and ANSI at the same time
::SetDlgItemTextW(this->GetSafeHwnd(), IDC_EDIT1, filetxt);
}
else
{
//ANSI files does not contain any headers, so we should
//reset the file pointer
f.SeekToBegin();
//we are going to load the text into a character array
char * filetxt;
//allocate a charaters array one for null terminator
filetxt = new char[dwFLen + 1];
//clear the filetxt array
memset(filetxt, 0, sizeof(char) * (dwFLen + 1));
f.Read(filetxt, dwFLen);
//use API function rather than MFC to be able
//to read UNICODE and ANSI at the same time
::SetDlgItemTextA(this->GetSafeHwnd(), IDC_EDIT1, filetxt);
}
f.Close();
}
</code>
|
|
|
|
|
Where about would I place this? Would it be right under the open dailog?
Thanks, I believe that you understood me correctly.
orcblood
|
|
|
|
|
I am sorry there was a little syntax error in the source code I submitted and I fixed it.
The follwoing code shows how to put the file opening code after the file open dialog.
if(openDlg.DoModal() == IDOK)
{
CFile f;
if(f.open(openDlg.GetPathName(), CFile::modeRead))
.
.
.
}
|
|
|
|
|
I was wondering if anyone knew how to do this. I have made several custom dialogs from my resource file but I don't know how to use them. I don't really know the structure for inserting a custom dialog either. So, could anyone tell me?
Thanks,
orcblood
|
|
|
|
|
|
This would work for a normal windows app too, right?
orcblood
|
|
|
|
|
As you seem to be very beginner, maybe you should work your way through the "Scribble Tutorial" found on MSDN[^].
Step 3 of that tutorial gives an excellent explanation of how to add dialogs to an MFC windows application.
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
How would i put a bitmap background onto my main frame and child windows?
also how would i stretch it to fit the entire window??
thanks
-perseus
|
|
|
|
|
Perseus wrote:
How would i put a bitmap background onto my main frame and child windows?
I think OnEraseBkgnd() would be the best place to draw a bitmap. Simply implement these methods in your frame and child windows.ö
The stretching could be done by using the function StretchBlt.
|
|
|
|
|
I'm working on an app that hooks the windows procedure for a given window (by using SetWindowLong() to replace the window procedure with my own). I'm unhooking my code during the processing of WM_DESTROY . All is going well for everything except modeless dialogs. For some reason a modeless dialog isn't receiving WM_DESTROY as a result of calling DefWindowProc() for WM_CLOSE .
Just to be sure I wasn't the cause of the issue, I whipped up an quick MFC test app without my code in place. In the app I create a dialog that contains nothing but the default buttons. In it, I put handlers for WM_CLOSE and WM_DESTROY , that look like this:
<br />
void CTestDlg::OnClose() <br />
{<br />
MessageBox( "Close" );<br />
<br />
CDialog::OnClose();<br />
}<br />
<br />
void CTestDlg::OnDestroy() <br />
{<br />
MessageBox( "Destroy" );<br />
CDialog::OnDestroy(); <br />
}<br />
If the dialog is created via DoModal() and I click the close box, everything goes as I'd expect it to. I see a "Close" message box, followed by a "Destroy" message box, and then my dialog disappears from the screen.
If, however, I instead create the dialog via a call to Create() and click the close box, I only see the "Close" message followed by the dialog disappering from the screen.
Just out of curiosity, I tried accessing the dialog after the processing of WM_CLOSE and discovered that the dialog window is still valid. If I call ShowWindow( SW_SHOWNORMAL ) , it returns to the screen and functions as though WM_CLOSE was never sent. For some reason, in the case of a modeless dialog, DefWindowProc() doesn't call DestroyWindow() , as it normally would.
As CDialog doesn't have an OnClose() function and the CWnd handler just passes it to Default() , I presume this behavior is bubbling up out of Windows default processing, but I haven't been able to confirm that to my satisfaction. MSDN documents (under 'Destorying the Dialog Box') that modeless dialog boxes will call DestroyWindow() in response to WM_CLOSE . This, however doesn't appear to be the case.
I've tested my sample app on Win2k and NT 4.0, with the same results.
Calling DestroyWindow() in the OnClose() of the dialog would work regardless of how the dialog was created, but since I'm injecting my code after the fact, not deriving from the dialog, that's not really an option for me.
Has anyone else encountered this / know of a work-around for it?
Dan
|
|
|
|
|
Try undoing the hooking after processing WM_NCDESTROY .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
Try undoing the hooking after processing WM_NCDESTROY.
It doesn't get WM_NCDESTROY either, because the window isn't being destroyed. That's my problem. It should destroy itself when it receives WM_CLOSE, but it doesn't.
|
|
|
|
|
This is a shot in the dark, but how about "delete this?"
Kuphryn
|
|
|
|
|
Hi,
1. Surely somebody here has written a really efficient and fast function which will replace special characters in a string with their XML entity equivalents? Every programmer using C++ and XML must surely have had to write this by now? I've just knocked a quick one up here:
void XMLSafeString(tstring& str)
{
int len = str.size();
TCHAR * buffer = new TCHAR[len+1];
_tcscpy(buffer, str.c_str());
str.reserve(len + 20);
str = _T("");
for(int i = 0; i < len; i++)
{
switch(buffer[i])
{
case _T('"'):
str += """;
break;
case _T('<'):
str += "<";
break;
case _T('>'):
str += ">";
break;
case _T('&'):
str += "&";
break;
case _T('\''):
str += "'";
break;
default:
str += i;
}
}
delete [] buffer;
}
but I'm sure there must be better ways. Also, I would like to see an efficient solution that doesn't modify the incoming string, but returns a tstring. The reason for this is:
2. I want to write out XML using the ofstream class. Unfortunately, I can't use the function I've got above without permanently modifying my input strings - which is a no-no. Therefore, I will have to copy every string into another object, and pass the xmlsafe-ised version of that string into the ofstream. This kind of reduces the simplicity of iostreams. Does anyone have anything clever like a modifier which enables XML character escaping?
Thanks in advance for any suggestions, code, etc...
Oh, and a quick disclaimer: I haven't tested the above code yet.
--
Simon Steele
Programmers Notepad - http://www.pnotepad.org/
|
|
|
|
|
Sounds like great work for regular expressions no?
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
Possibly, but will this be faster than my brute force replacer? Also, it involves the inclusion of a regular expression library. I'm not against the idea, but it has drawbacks.
Also, would I have to use x different regexs where each x represents one transformation:
" -> "
' -> '
...
or is there a way I can do all of these with one regex?
Thanks for your help,
--
Simon Steele
Programmers Notepad - http://www.pnotepad.org/
|
|
|
|
|
Firstly, the above code contains a bug:
str += i;
should be:
str += buffer[i];
Also, I have found a simple way of using the above function with iostreams. It works like this:
struct FormatXML {
tstring str_;
explicit FormatXML(const tstring& str) : str_(str) { XMLSafeString(str_); }
friend std::ostream& operator<<(std::ostream& s, const FormatXML& x)
{
s << x.str_;
return s;
}
};
This copies the input string, and performs the XML safety check on construction. The safe string is then passed into the stream. It would be used like this:
<br />
tstring str = _T("My string with \"Quotes\".");<br />
myostream << FormatXML(str);<br />
This isn't very efficient, however. Therefore, I'm still on the lookout for cool code. Let me know!
--
Simon Steele
Programmers Notepad - http://www.pnotepad.org/
|
|
|
|
|
Win32 question: anyone know what font and character used to draw the bullets in a password edit control in XP with Visual Styles turned on?
Background: for historical reasons related to resources and performance on Win16, as well as to reduce flicker when resizing, my Win32 app draws all controls on a window. For edit controls it only moves a REAL edit control into place when the user tries to move the focus there. When the focus moves out, the real edit control becomes invisible again (or is moved to wherever the focus moved, if that was another edit control).
On XP we have visual styles turned on (using a manifest). We call the Theme API functions in uxtheme.dll to simulate the drawing of controls. When visual styles are turned on, bullet points are drawn instead of asterisks. Unfortunately, the Theme API does not provide a "password state" for drawing an edit control. See the Parts and States table[^].
When focus moves out of a password edit control (one with the ES_PASSWORD style), we draw the edit control ourselves. Our old code was drawing asterisks and it looked fine. On XP we're trying to figure out what font and character the edit control uses to draw the password characters.
The documentation for the ES_PASSWORD style says this:
Microsoft® Windows® XP: If an edit control is from user32.dll, an asterisk is the default character for the ES_PASSWORD style. However, if an edit control is from comctl32.dll version 6, a black circle is the default character for the ES_PASSWORD style. Note that comctl32.dll version 6 is not redistributable but is included with Microsoft® Windows® XP or later. To use comctl32.dll version 6, specify it in a manifest. For more information on manifests, see Using Windows XP Visual Styles[^].
I tried sending EM_GETPASSWORDCHAR to the edit control. The result was -59 decimal, or 0xCF. In most fonts this is a capital I with an umlaut. I can't find any symbol font where this is a bullet point.
We've already tried a few bullet points in a few fonts, but can't seem to find one that's the right size and char width. When the user tabs out of the password field, it looks funny because the bullets shift.
- Brian Morearty
|
|
|
|
|
I do not know exactly how your code works, but as I understand you draw the edit control part by part as an image on th parent window DC when it is not focused.
Did you try to get the DC of the control directly and blitting it? By that you will just copy the edit's look just as the window draws it however it do it.
this is sample code may explain what i mean:
<br />
CClientDC dc(this);
GetDlgItem(IDC_EDIT1)->HideCaret();
CWindowDC tempDC(GetDlgItem(IDC_EDIT1));
CRect rct;<br />
GetDlgItem(IDC_EDIT1)->GetWindowRect(rct);<br />
ScreenToClient(rct);
<br />
dc.BitBlt(rct.left, rct.top, rct.Width(), rct.Height(), &tempDC, 0, 0, SRCCOPY);<br />
GetDlgItem(IDC_EDIT1)->ShowCaret();
|
|
|
|
|
Thanks for the suggestion, MAAK. Not bad. I'll keep it in mind if nothing better comes up, although I'd prefer to draw password edit controls the same way we draw all other edit controls--and without having to keep a bitmap for each one.
- Brian Morearty
|
|
|
|
|