|
In the release build, _DEBUG isn't defined. #ifndef _DEBUG evaluates to true at compile time and code is included.
ns wrote:
Or is there something like _RUN or something that makes code run at runtime thats within #ifdef _RUN execute?
I don't know what do you mean by this.
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
I have 10 items in the listbox.when i scroll the vertical scroll bar downwards,say some three items gone up.So the first three items is not visible to user.How to programmatically find out that the first three items is not visible.
|
|
|
|
|
GetTopIndex() will tell you which is the top visible item. After that, it's not rocket science to figure it out.
Steve S
[This signature space available for rent]
|
|
|
|
|
Just for the rocket scientists out there;P
If you know the height of one item (htItem), (LB_GETITEMHEIGHT) and you know the client height of the list (htClient), you can, by dividing htClient by htItem, determine the number of visible items.
If you then know the top index, you can also work out the bottom index.
To make items become visible programmatically, you can scroll the list by calling SetTopIndex (in MFC, message is LB_SETTOPINDEX) appropriately.
If you resize the list box, you have to recalculate, of course
Steve S
[This signature space available for rent]
|
|
|
|
|
I'm migrating from VC++ 6.0 to VS.net. I created dialog resources, but don't know how to create a CDialog derived dialog for it the dialog resource.
|
|
|
|
|
Open popup menu above dialog resource and choose "Add Class".
|
|
|
|
|
I don't see "Add Class". I only see "Add Class" when I selected the project name, but it just show me a normal Class add dialog without the way to specific the Dialog template resource.
When i right click in the dialog resource, I see
Cut
Copy
Paste
Delete
--------
Resource Includes
Resource Symbols
--------
Open
Open Binary Data
--------
Save Myproject.rc
Add Resource...
Insert Copy
Insert Dialog
Export
|
|
|
|
|
There is no anything surprising because you click in resource tree window although the right way is to click on dialog itself
|
|
|
|
|
Thanks very much. I got it. No matter why I coudln't find it coz i was puzzling with the resource tree. haha ...
|
|
|
|
|
Hello world.
Can anybody tell me what's the difference between those MACRO in MFC:
ASSERT( booleanExpression )
and:
VERIFY( booleanExpression )
I know what they mean but I don't see any difference...
Thanks in advance...
Hello World!!!
from Raphaël
|
|
|
|
|
Unless AdamUK beats me to it again...
ASSERT disappears in a release build, while VERIFY doesn't.
For example,
ASSERT( ( p = somefunction() ) != 0)
VERIFY( ( p = somefunction() ) != 0)
In the first case, the code is =eliminated= and will more than likely cause some hapless (or should that be witless) developer to tear out their hair trying to figure what's gone wrong. In the second case, the code is retained, but no test is actually performed.
At least, that's how they used to work...
Steve S
[This signature space available for rent]
|
|
|
|
|
check out this link for more info:
http://gamedev.net/reference/articles/article1846.asp
|
|
|
|
|
if (remaining & pAccess->dwValue)
{
remaining &= ~pAccess->dwValue;
}
remaining is a typedef DWORD structure and pAccess is a structure and dwValue is DWORD type.
What does one & mean?And what does its next line means?:remaining &= ~pAccess->dwValue;
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Mazy,
The & operator is the bitwise 'AND' operator. Your code takes dwValue and performs a bitwise and operation with remaining. Eg if remaining = 0000101011 and dwValue = 0100011001 then the result is 0000001001 (in binary)
If the if statement is nonzero, it executes the remaining code.
x&=y is equivalent to x=x & y (the bitwise operator again)
~ is the bitwise ones complement (or NOT operator) i.e. 010101 becomes 101010 in binary.
So, remaining &=~pAccess->dwValue is equivalent to
remaining=remaining & ~pAccess->dwValue
Hence the bits in dwValue are complemented (ie. all the 1s turn to 0s and the 0s turn to 1s) it is then 'AND'ed with remaining and the result stored in remaining .
Hope this clears things up
Adam.
www.beachwizard.com/travelogue[^]
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
Thank you very much.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Relatively simple, & is a binary AND, while ~ is a binary NOT.
For instance, if "remaining" contains 127 (0x7F, or 01111111 binary),
and pAccess->dwValue contains 6 (0x6, 0110 binary), the ~ flips the bits
in pAccess->dwValue, so it contains 0xFFFFFF9, and then it's ANDed with
the "remaining" value
0111 1111 (remaining)
1111 1001 (dwValue)
---------
0111 1001
which is then stored in remaining.
It's a common technique used to turn off bits in one value that are set in another.
Steve S
[This signature space available for rent]
|
|
|
|
|
Thanks.I got the point.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
I have list box.When I fill it for second time I want previous items deleted and new ones shown.I use ResetContent but items do not deleted.I use this code:
m_listgrowp.ResetContent();
for(int i=0;i<(int)strSidArray.GetCount();i++)
m_listgrowp.AddString(strSidArray.GetAt(i));
strSidArray.RemoveAll();
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Set breakpoint to line "m_listgrowp.ResetContent()", Type "ERR,hr" in watch window. You will see the GetLastError() string message. May be, it will help you.
|
|
|
|
|
Thanks.I'll do it.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
I have written some code to save a CString to a file with the WriteFile API function (I prever to use the API function and not the CFile member functions).
CString str = _T("HI");
if (!WriteFile(hFile, str, str.GetLength(), &dwWrittenBytes, NULL) ||
dwWrittenBytes != (DWORD) str.GetLength())
{
AfxMessageBox(_T("Could not write to file."), MB_OK | MB_ICONEXCLAMATION);
return FALSE;
}
On Windows XP (or other Windows Systems) it works fine, but when I use the code in Embedded Visual C++ 3.0 in the Emulator I have to change the code like the following, to get the same result as under WinXP.
CString str = _T("HI");
if (!WriteFile(hFile, str, str.GetLength() * 2, &dwWrittenBytes, NULL) ||
dwWrittenBytes != (DWORD) str.GetLength() * 2)
{
AfxMessageBox(_T("Could not write to file."), MB_OK | MB_ICONEXCLAMATION);
return FALSE;
}
I have to write twice as much characters (str.GetLength() * 2) to get the same result! Is that something with Unicode? Can anyone explane me that? And, how I have to write this function that it works under both systems (XP and CE)?
(When I debug the code in Embedded VC++ 3.0 and I look the memory where the string in CString is saved, every second character is 0, like 'H|I|' --> | is for 0.)
--
Nice greets, Daniel.
|
|
|
|
|
Third parameter of WriteFile is buffer size in bytes. sizeof(char) in UNICODE is 2. In both cases you should write:
WriteFile(hFile, str, str.GetLength() * sizeof(TCHAR), ...
|
|
|
|
|
Thanks!
--
Nice greets, Daniel.
|
|
|
|
|
Putting a recent file list into my MFC-based app was a no-brainer, but there's something I'm having trouble with.
If I select a file from the Recent list that's currently open, MFC magically avoids calling OnOpenDocument() in my doc class. While this is desirable behavior in most cases, for my particular app I need to reopen the file instead.
Any ideas on how to tweak the behavior?
|
|
|
|
|
Override the CWinApp::OpenDocumentFile ?
Steve S
[This signature space available for rent]
|
|
|
|