|
One possible reason that springs to mind is that the file somehow contains an embedded null. If this is true, strTemp probably *is* being added, but the embedded null stops the variable watch window from displaying the entire string. Also, if you try and use string manipulation routines on m_strFileBuffer, they will be affected by this null equally, and terminate the string early.
To test if this is the problem, try modifying your code to this:
CString strTemp;
const int MAX_LINE_LENGTH_EXPECTED = 1024 ;
TCHAR cBuffer[MAX_LINE_LENGTH_EXPECTED + 1];
while( ar.ReadString(cBuffer, MAX_LINE_LENGTH_EXPECTED) != NULL)
{
if (cBuffer[_tcslen(cBuffer) - 1] != _T('\r')
&& cBuffer[_tcslen(cBuffer) - 1] != _T('\n') )
{
// We may have a prematurely-truncated string.
// Or it will be the end of the file {:v)
assert(false); <=== put breakpoint on this line.
}
m_strFileBuffer += strTemp + _T(" ");
}
If there's an embedded null, the character found at where it believes the end of the string is will *not* be the <cr> / <lf> it should be. Obviously the genuine end of the file may also not end with CR / LF, so be prepared for that.
If you think your file might contain lines longer than 1024, adjust MAX_LINE_LENGTH_EXPECTED as appropriate.
|
|
|
|
|
Hey Freinds
I have a webbrowser control which displays a page , which has hyperlinks.
Is there any way by which if user clicks on any of the hyperlink(s) and the page should be opened another webbrowser control?
Regards
|
|
|
|
|
This[^] article demonstrates how to 'catch' navigations from the WebBrowser control. You can handle the OnBeforeNavigate2 event, which lets you redirect navigations elsewher.
Software Zen: delete this;
|
|
|
|
|
I have a hashing function for strings as follows:
<br />
template <int HASHSIZE>
class string_hash_nocase<br />
{<br />
public:<br />
int operator()(const char* s)<br />
{<br />
int hash = 1048577;<br />
char c;<br />
<br />
while (*s)<br />
{<br />
c = (*s >= 0x61 && *s <= 0x7a) ? (*s & 0xdf) : *s;<br />
hash = ((hash << 5) + hash) ^ c;<br />
++s;<br />
}<br />
<br />
return hash & (HASHSIZE - 1);<br />
}<br />
};<br />
May you have any idea on how to modify/extend it for Unicode (const wchar_t* )?
|
|
|
|
|
It looks similar to the djb2 hash.
I don't know why the lower case filter is there (*s >= 0x61 && *s < 0x7a) as it just filters out bit5 - never seen that done on a string hash before.
The lower-case filter isn't going to work in unicode as you don't know that the language will be english, however; if you really want to keep it try this:
int operator()(const wchar_t* s)
{
int h = 1048577;
wchar_t f = 0xdfdf,
c = 0;
while( *s ) {
c = iswlower(*s) ? (*s & f) : *s;
h = ((h << 5) + h) ^ c;
++s;
}
return h & (HASHSIZE - 1);
}
Not knowing how the 0xdf was chosen in the original i don't know if you should use 0xdfdf or 0x00df for f ... or something else entirely.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
in my C++ app, i need to calculate curve length numerically.
let me say:
y=F(x);
d=x1-x0 is very small
curve length from x0 to x1 may be calculated as:
s=sqrt((y1-y0)*(y1-y0)+d*d);
where y1=F(x1), y0=F(x0);
s is straight line length from (x0,y0) to (x1,y1) actually.
result is not accurate.
i can not find aticles to get better result for general curve length in google, do u know any?
thx.
|
|
|
|
|
It is better to go through the book on numerical analysis.
You will find many methods there.
|
|
|
|
|
|
the program can do some numerical methods like taylor-mclauren. MOSS,newton-raphson method, secant method, bisection method,false position method and bairstow's method, curve fitting.
i'll be really grateful for any help for any of those methods.
thanks!!!
|
|
|
|
|
can somebody help me?..
-- modified at 4:48 Tuesday 4th September, 2007
|
|
|
|
|
hi, im sure this question is a regular one.
i'm making an app with bitmapbuttons and want to change bitmap on the button when hovering over them
can't seem to find any good articles about this subject.
heres a code i've been trying out, cant seem to get it to work.
//loaded the default button bitmaps in
OnInitDialog()
m_btn1.LoadBitmaps(IDB_MYBUTTON_DEFAULT);
//this works and sets the bitmaps on my buttons
//something like this is what i want to do
void CMyDlg::OnMouseMove(UINT nFlags, CPoint point)
{
CRect m_Rect;
m_btn1.GetWindowRect(m_Rect);
if (m_Rect.PtInRect(point))
{
//when mouse is over button change to this bitmap
m_btn1.LoadBitmaps(IDB_MYBUTTON_OVER);
}
}
any solutions?
tanx
|
|
|
|
|
You won't get a WM_MOUSEMOVE message in the dialog when the cursor is
moved over a button. You need to check for WM_MOUSEMOVE in the button class.
In your button class' OnMouseMove(), the first time it's called when the cursor
enters the button, you can use TrackMouseEvent() with the TME_LEAVE flag. Then
you'll get a WM_MOUSELEAVE message when the cursor is moved off the button
so you can set the bitmaps back to the original.
Also, after your LoadBitmaps() calls, you may need to call UpdateWindow() on the
button(s) to get them to redraw (maybe not, but if the button bitmaps aren't changing,
it's worth a try ).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
tanx, i'll try that!
|
|
|
|
|
Given the coordinates on the desktop, how could I get a handle to the window at that position.
Sample code will be ok too. Thank you very much.
Tmay_99
|
|
|
|
|
POINT point={100,200};
HWND hWnd=::WindowFromPoint(point);
if (hWnd) {
// Do something
} else {
// Nothing here
}
|
|
|
|
|
Thank you very much. Well I have another question, does the handle I get with this code belong to a top-level window or a child window. If it is a child window, how could I get the top-level window? Thank you.
Tmay_99
|
|
|
|
|
POINT point={100,200};
HWND hWnd=::WindowFromPoint(point);
HWND hWndParent=NULL;
if (hWnd) {
// Find the highest level parent
do {
hWnd=::GetParent(hWnd);
if (hWnd) {
hWndParent=hWnd;
}
} while (hWnd);
}
if (hWndParent) {
// do something with highest parent
}
|
|
|
|
|
Well, I'm not sure if you wanted the parent or just the top-most z-order child window.
Let me know if I misunderstood your second question.
|
|
|
|
|
If I'm missing the mark on this one, you can check out the explanations of the relationships and functions to find them if you open up MSDN, click on the search tab, and find "Win32 Window Hierarchy and Styles".
It goes over the relationships and functions.
|
|
|
|
|
Wow,thanks a lot.Yes, I want the top-level window which GetParent returns NULL. I appreciate your help!
Tmay_99
|
|
|
|
|
Hi ,
i built an SDI Project (RTFView) and i want to edit displayed Text in the fonttype "Terminal" (OEM/DOS Font).
I try this with the CFONTDialog. I can now change the text in every fonttype but not in "Terminal".
Do yo know how i can do this ? Is there a tut or a Code snippet or can you explain how i can fix this Problem ?
Here is my code:
[CODE]
void CTereader0004View::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
CTereader0004Doc *pDoc = GetDocument ();
CRichEditCtrl& rCtrl = GetRichEditCtrl(); // Pointer auf das RichEditControl erstellen um dessen Funktionen zu nutzen
CHARFORMAT cfm; // Struktur die die Aktionen der Selektion enthält/ CFont myFont;
rCtrl.ReplaceSel(pDoc->cstrAusgabe);
rCtrl.SetSel(0,482);
cfm.cbSize = sizeof(CHARFORMAT); // Funktionen
cfm.dwMask = CFM_BOLD; // des RichEditCONTROLS zur
cfm.dwEffects = CFM_BOLD; // formatierten Darstellung benutzen
rCtrl.SetSelectionCharFormat (cfm); // Aktionen der Selektion ausführen
rCtrl.SetSel (0,0);
rCtrl.SetModify(FALSE);
}
void CTereader0004View::OnFontChoose()
{
CFontDialog fontDlg;
CFont *m_font = new CFont;
if (fontDlg.DoModal())
{
m_font->CreateFont (fontDlg.GetSize() / 7.25
,NULL
,0
,0
,fontDlg.GetWeight ()
,fontDlg.IsItalic ()
,fontDlg.IsUnderline ()
,fontDlg.IsStrikeOut ()
,DEFAULT_CHARSET
,OUT_DEFAULT_PRECIS
,0
,DEFAULT_QUALITY
,DEFAULT_PITCH
,fontDlg.GetFaceName ());
}
CRichEditCtrl& rCtrl = GetRichEditCtrl(); // Pointer auf das RichEditControl erstellen um dessen Funktionen zu nutzen
CHARFORMAT cfm;
rCtrl.SetFont (m_font);
}
[/CODE]
many many thx
CrocBuck
|
|
|
|
|
O.K.
I solve the prob.
CrocBuck
|
|
|
|
|
Hi anyone knows if I can get Visual Studio Express on a disc? Installer from Microsfot's site works but our network guys have blocked the installer from downloading packages for installation to complete.
Thanks
|
|
|
|
|
Yes, it's possible, I think you can order it from MS for $5 or something. I know it can be done, I've got teh DVD.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|