|
I didn't call RecalcLayout(TRUE) before. But I just add that line into my code. It still does not help. What I am trying to do here is change window's size a little then resume it back to its original position without being noticed by end user. It is not working! Everytime I run the application, the window gets shrunk in its height. Any ideas? Thanx.
CRect rect;
GetClientRect( &rect );
int x = rect.left;
int y = rect.top;
int cy = rect.Height();
int cx = rect.Width();
// move RecalcLayout() after SetWindowPos(), still the same
RecalcLayout(TRUE);
SetWindowPos( NULL, rect.left, rect.top, rect.Width(), rect.Height()+ 1/1000, SWP_NOZORDER | SWP_NOMOVE);
// resume window to its previous position
SetWindowPos( NULL, x, y, cx, cy, SWP_NOZORDER | SWP_NOMOVE);
|
|
|
|
|
It is working now! Thanks for your suggestion.
Just put RecalcLayout(TRUE); No need to play with window size.
|
|
|
|
|
After toolbar initialization I call CToolBarCtrl::AutoSize()
|
|
|
|
|
Hi,
Maybe there is somebody who knows what may be wrong or has experienced the following problem:
I have an application which uses the PC's communication port. It uses "CreateFile" to create a virtual "file" on the comm port and simply uses WriteFile to write to it. Generally it works just great, sometimes for hours on end. Then all of a sudden the "WriteFile" returns an error in the same way it would do in case the "WriteFile" cannot be completed in one go . This is weird because I never send more then a few dozen bytes anyway and take care to space all transmission quite well. Still, I then use "GetOverlappedResult" to find out what is going on. Sure enough it says ERROR_IO_INCOMPLETE and keeps on doing so for ever. I have set up a timeout function on it to trap the condition and simply discard the outgoing message (there are plenty retries etc... at the higher application levels anyway). I perform "ClearCommError" and "CancelIo" to try and correct things but that does not always work. Sometimes having done it once the Writefile keeps giving back the same error continuously. having done it often enough this sometimes leads to the PC crashing quite spectacularly.
Anybody have any ideas or knowledge about this ? Any help would be most appreciated
Regards,
Filip
|
|
|
|
|
is there anything wrong with my 'for' statement here?
when i run the program, it says assertion failure... at line 222 of AFXCOLL.INL which is:
line 221: _AFXCOLL_INLINE CString CStringArray::GetAt(int nIndex) const
line 222: { ASSERT(nIndex >= 0 && nIndex < m_nSize);
CString sLevel;
int nCount;
for (int i=0; i <= 9; i++)
{
sLevel.Format("%d=", i);
CStringParser p3(sBufferList.GetNext(pos), sLevel); //parse RegisterList in lines of text
int nCount = p3.GetCount();
if (nCount > 0) //found more than one line of text in RegisterList
{
for (int j=2; j <= nCount; j++)
{
pos = sBufferList.AddHead(p3.GetField(j));
if (j>2)
ParseLevel(sBufferList.GetAt(pos), i);
}
}
}
please help!!
|
|
|
|
|
1 CString sLevel;
2 int nCount;
3
4 for (int i=0; i <= 9; i++)
5 {
6 sLevel.Format("%d=", i);
7 CStringParser p3(sBufferList.GetNext(pos), sLevel);
8 int nCount = p3.GetCount();
9
10 if (nCount > 0)
11 {
12 for (int j=2; j <= nCount; j++)
13 {
14 pos = sBufferList.AddHead(p3.GetField(j));
15 if (j>2)
16 ParseLevel(sBufferList.GetAt(pos), i);
17 }
18 }
19 }
1) You have nCount defined outside the scope of the "for" loop, as well as *inside* the scope. Is this really what you wanted?
2) You're passing a string in as a delimiter - it should actually be a single character. Onl line 6, your first delimiter is going to be a null character followed by an equal sign. I think what you wanted to do was extract a character from a string that contains several delimiters.
3) I never anticipated anyone using a NULL as a delimiter. I recommend you don't try it.
Looks like you're parsing a string that has several nested delimiters (HL7?)
|
|
|
|
|
1) the redefinition of nCount was a mistake, it is meant to be outside the 'for' loop.
2) I have modified the StringParser class to accept a CString argument instead of a char argument. Will it still work? and is this error due to the change?
please advise.
|
|
|
|
|
If you modified my original code, I can't really tell you if that's why it doesn't work unless I see the changes. By the way, there is an updated version I posted yesterday - is that the version you're using?
I've never seen delimiters that were multi-character strings. Can you describe the task you're trying to address with this code? Maybe we can come up with a different tack.
|
|
|
|
|
I want to parse a some text from a file. The format of the text goes something like this:
#BeginRegisterList
0= RegisterName A2 D2;
1= "Control Set";
2= Byte control &c5;
#EndRegisterList
I have converted the text from the file into a CString object, so that I can pass it into the StringParser functions.
I was able to use the modified StringParser class (I only changed the delimiter data type for "char" to "CString") to extract the lines between "#BeginRegisterList" and "#EndRegisterList" (I used these strings as the delimiter), leaving behind the following lines:
0= RegisterName A2 D1
1= "Control Set"
2= Byte control &c5
bit control
my problem arose at the point whereby I use a 'for' loop to extract the various parameters to be stored in the document:
RagisterName
2
1
Control Set
Byte Control
c5
bit control
the 'for' loop is to change the delimiter from "0=", "1=", ... "9=".
I hope the explanation is clear. I downloaded your code last week. will download the latest version now.
|
|
|
|
|
I'm leaving for work - I'll answer this when I get there. Do not dispair.
|
|
|
|
|
I have changed to the latest version and the 'for' loop works! I dunno what went wrong really. The old StringParser class still doesn't work.
Maybe you would like to take a look at the changes I made to your updated source code, using CString as delimiter. I have added another private member variable m_cDelimiterLen to adjust the workString for in the function CQStringParser::ParseString(). Will send the modified source files to your email.
|
|
|
|
|
I would use just the ' ' (space) character as the delimiter. This would result in the following:
//string 1
CStringParser("0= RegisterName A2 D2", ' ', '\"');
GetField(1) - "0="
GetField(2) - "RegisterName"
GetField(3) - "A2"
GetField(4) - "D2"
//string 2
CStringParser("1= /"Control Set/"", ' ', '\"');
GetField(1) = "1="
GetField(2) = ""Control Set""
GetField(2, TRUE) = "Control Set" // strip the quotes from the string
//string 3
CStringParser("2= Byte Control %c5", ' ', '\"');
GetField(1) - "2="
GetField(2) - "Byte"
GetField(3) - "Control"
GetField(4) - "&c5"
If you wanted to, it would be a simple matter (with the latest version of CStringParser) to modify the sub-strings (removing the '=' or leading spaces) by creating your own derived CStringParser class and handling the special cases as they arise without the need to change the underlying base class.
|
|
|
|
|
just wondering,
if I use a white space character ' ', the code does not detect the tabs spaces. Is there any way I can make the tab space(s) = a single white space?
Wat delimiter should I use if I want to parse my string into lines of text. Should the delimiter be the end-of-line (or is it some linefeed or CR character) character? If yes, what is the character?
Please provide me with some sample code if possible.
Thanks a lot!
|
|
|
|
|
I think your problem was with CStringArray(). I used CArrays() in my program and it was sometimes very hard to find out what causes the problem - one time it worked and one it doesn't. And even if you passed the same type of variables to it! I just had to rebuild the whole functions sometimes to make it work. Sometimes it worked if you rebiudl the whole project and sometimes when you restart VS - maybe it uses some kind of cache memory?
Microsoft knows.
Greets,
|
|
|
|
|
Hi
I'm a Korean..
How to control the other program(for example, MS Word, Internet Explore etc...)'s scrollbar?
For example, when any button in my program is clicked,
my program want to know other program's scrollbar's "range"(or page, position) in client area.
how to???
|
|
|
|
|
Why on earth would you want to do *that* ?
If you enumerate the windows in some manner you can get the CWnd of another Window, then I presume you can call SetScrollPos, etc.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
Hi Christian.
But how can i get CWnd pointer from other program ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Like this
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
char* h = new char[255];
GetWindowText(hwnd,h,255);
CString text(h);
long wl = GetWindowLong(hwnd,GWL_STYLE);
CArray<cstring, cstring="">* lb = (CArray<cstring, cstring="">*)lParam;
if (text.GetLength()>0 && IsWindowVisible(hwnd) &&
text != "Program Manager" && text != "Window Popper")
lb->Add(text);
return TRUE;
}
In my code, lParam is a CArray ( nowadays I would use a vector ), and I check the title of the window to see if it's one I want to ignore and if it's visible ( not doing the visibility check gives you a gazillion hidden windows ) and then pass the title into my list. Then I do this in my main code:
CArray<cstring, cstring=""> list;
EnumWindows(EnumWindowsProc, (long)&list);
and I can do this:
CWnd *pOtherWnd = CWnd::FindWindow(NULL, name);
if I find the Window I want ( for example, I might search for the first four letters of the title to be Word, but the next three not to be Pad ), then I get the CWnd by calling FindWindow. If I know for sure something is running and it's full title, then I can just go to this step.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
Hello everybody,
Iam a newbie to ATL&ADOs.I am developing an ATL component which is to store some binary data in to a table using ADOs.I have a problem with storing of binary data. I don't know how to pass a parameter along with the SQL query, that's why i am using a sample ADO dll(adosamp) which is there in MSDN samples. I am getting the binary data (which may have null characters in between) thru a ptr to the buffer (char*) from another dll, after that i am using CComVariant to encapsulate that buffer (char*) & passing along with SQL query as a parameter. In the data that i am getting, the second character itself is null char (ASCII 0). I tried asigning the buffer's data (char*) in 2 ways
one is
passing the char* in constructor of CComVariant as CComVariant vt(buff)
and passing it's length as 195. if i do so it's taking the CComVartiant as of type VT_BSTR, the data getting stored is first 2 chars only (terminated with null char).
Second is
i have assigned the char* to "pcVal" field of CComVariant and set type of the CComVariant as VT_BYREF|VT_I1 & passing the length of buffer as 195. when i did so it's giving an error stating that
" Invalid string or length".
The data in CComVariant variable is there till the execute command.
How can i solve this problem & insert binary data in table(Access)?
Also tell me how to pass the buffer along with the SQL query as a parameter?
Thanks in Advance.
My e-mail id kgrajashekar@usa.net
|
|
|
|
|
convert the data bytes to text (inc 0 for zero's) and send them as a string into the db
ie, "hello world0It is a nice day0"
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Thanks for reply.
But Sorry lauren,
i didn't get u, what do u mean to say, please elobarate it.
|
|
|
|
|
well supposing you have binary data as follows:
765076004325600tsktsk00876
convert it to a ascii representation and in the sql statement that updates the db instead of using a numeric type to make the query text use a string type ... the db will convert it back to binary on the insert
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Couldn't he also use a SAFEARRAY of characters? That would preclude him from having to convert characters, and what if there's actually zero's in the blob of data?
I'm certainly no COM expert (far from it actually), but it seems a SAFEARRAY would be, ummm, safer.
|
|
|
|
|
awwwww ... where's the fun in that
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
I think he's past the "having fun" part...
|
|
|
|