|
The 'Build Lob' is a tennis hit, aimed to step over high obstacles, like buildings.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hello everybody !
In the project , I read the data from SQL2000,and use SetItem to set the strings.
some specified column I want to set the text color,How can I do it?
Thanks for your reply !
Best Reguards!
|
|
|
|
|
Please search for articles on List Controls. There are plenty of those at CodeProject, explaining what you're after.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
thanks !
|
|
|
|
|
You need to do custom draw in CListCtrl.
This article in CP might help you [^]
|
|
|
|
|
thanks!
|
|
|
|
|
|
I ‘inherited’ some small VC6 c++ project, which creates Win service. I build it in VS2008, but it could not find included Event Messages in it.
Messages should be included in exe not dll ( program itself runs ok: I’m able to register service, run it and stop it.) I have one more rc file in project. So, I have LogMsg.mc with messages and MyPrjct.rc with other resources. During compile time mc.exe (I have SDK 6.1) creates three files:.bin, LogMsg.h, LogMsg.rc. Header file goes into MyPrjct.cpp; I put line ‘#include “LogMsg.rc”’ into MyPrjct.rc, and use ReportEvent(…) to retrieve/write event message, using SymbolicName, but it could not find messages exe.
I need to solve this problem as fast as possible.
|
|
|
|
|
Hi every one,
What is MAX_INT in C for??
|
|
|
|
|
(BTW, it's INT_MAX)
To know what the maximum value of an int is, which can vary from platform to platform. Traditionally, an int was the optimal size of data that the CPU could deal with (either a register size or what was pushed onto the stack.) So, in the 8086 world, an int was 16-bits long. (With some CPUs an int could be 8-bits long, though I've never personally seen that.)
Typically, an int is now considered to be 32-bits long, even on 64-bit systems. (Some operating systems consider long to be 32-bits, others 64-bits.)
I often use INT_MAX for the default value of a length parameter with string parsing functions where I am to parse n characters or until the terminating zero, whichever comes first.
|
|
|
|
|
|
Why such a doubt?
integer's value depends with compiler.
For 16 bit turbo c, its value -32,767 to 32,767
But for 32 bit vc, it value is 4,294,967,296 for unsigned.
so this value can be useful.
Величие не Бога может быть недооценена.
|
|
|
|
|
In theory - it depends on processor data "word" size and not on software (e.a. compiler) running on it.
Unsigned integer on 4 bit mashine has max size of decimal 16.
|
|
|
|
|
An int is a logical construct of a programming language. While the register of a CPU often determines the maximum size of an int, this is by no means a requirement of a compiler. (For example, there are 8-bit microprocessors that can mimic 16-bit operations.) Furthermore, as register sizes have increased to 64-bit, an int in C/C++ has tended to stay at 32-bit (in part because that would leave a hole in the data size scheme.)
|
|
|
|
|
It is platform dependent constant which is proposed by ANSI.
And if you take a work with a 16 bit Turbo C compiler on a 32 bit processor.
The value of int will be -32768 to 32767. So i believe it depends on compiler, isnt it?
If i am wrong please do correct.
Величие не Бога может быть недооценена.
|
|
|
|
|
It's entirely dependent on the compiler, which is why I corrected Vaclav_Sal.
The only requirement is that the size of an int is as big or bigger than that of a short and as big or smaller than that of a long. A compliant compiler could make a char, short, int and long all 5 bits long if it chose. Likewise, it could make them all 64-bits long regardless of the underlying CPU and/or system architecture.
However, Vaclav_Sal is correct if he's suggesting that in the past, an int generally reflected the optimal "WORD" size of a CPU--a point I made earlier. However, for 64-bit and greater processors, int has lost that meaning and is generally 32-bits long.
|
|
|
|
|
Thanks
Величие не Бога может быть недооценена.
|
|
|
|
|
I created a listbox (owner drawn) using the code given below. the problem with my application is that when i click on any item in the listbox it gets selected .
how to rectify that ?
Here's my code :-
CChatHistory is my ListBox's class name
#include "stdafx.h"
#include "sock.h"
#include "ChatHistory.h"
IMPLEMENT_DYNAMIC(CChatHistory, CListBox)
CChatHistory::CChatHistory()
{
}
CChatHistory::~CChatHistory()
{
}
BEGIN_MESSAGE_MAP(CChatHistory, CListBox)
END_MESSAGE_MAP()
void CChatHistory::AddItem(const CString& str, COLORREF rgbText)
{
int nIndex;
nIndex = AddString(str);
if( CB_ERR != nIndex )
SetItemData(nIndex, rgbText);
}
void CChatHistory::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
CDC dc;
CRect rcItem(lpDIS->rcItem);
UINT nIndex = lpDIS->itemID;
COLORREF rgbBkgnd = ::GetSysColor((lpDIS->itemState & ODS_SELECTED) ?COLOR_HIGHLIGHT : COLOR_WINDOW);
dc.Attach(lpDIS->hDC);
COLORREF crOldTextColor = dc.GetTextColor();
COLORREF crOldBkColor = dc.GetBkColor();
CBrush br(rgbBkgnd);
dc.FillRect(rcItem, &br);
if( lpDIS->itemState & ODS_FOCUS )
dc.DrawFocusRect(rcItem);
if( nIndex != (UINT)-1 )
{
COLORREF rgbText = (lpDIS->itemState & ODS_SELECTED) ?::GetSysColor(COLOR_HIGHLIGHTTEXT) : GetItemData(nIndex);
CString str;
GetText(nIndex, str);
dc.SetBkColor(rgbBkgnd);
dc.SetTextColor(rgbText);
dc.TextOut(rcItem.left + 2, rcItem.top + 2, str);
}
dc.SetTextColor(crOldTextColor);
dc.SetBkColor(crOldBkColor);
dc.Detach();
}
void CChatHistory::MeasureItem(LPMEASUREITEMSTRUCT lpMIS)
{
CClientDC dc(this);
TEXTMETRIC tm;
CFont* pFont = GetFont();
CFont* pOldFont = dc.SelectObject(pFont);
dc.GetTextMetrics(&tm);
dc.SelectObject(pOldFont);
lpMIS->itemHeight = tm.tmHeight + 4;
}
int CChatHistory::CompareItem(LPCOMPAREITEMSTRUCT lpCIS)
{
CString str1, str2;
GetText(lpCIS->itemID1, str1);
GetText(lpCIS->itemID2, str2);
return str1.Compare(str2);
}
Future Lies in Present.
Manmohan Bishnoi
|
|
|
|
|
Remove the following lines from the DrawItem method.
if( lpDIS->itemState & ODS_FOCUS )
dc.DrawFocusRect(rcItem);
if( nIndex != (UINT)-1 )
{
COLORREF rgbText = (lpDIS->itemState & ODS_SELECTED) ?::GetSysColor(COLOR_HIGHLIGHTTEXT) : GetItemData(nIndex);
CString str;
GetText(nIndex, str);
dc.SetBkColor(rgbBkgnd);
dc.SetTextColor(rgbText);
dc.TextOut(rcItem.left + 2, rcItem.top + 2, str);
}
|
|
|
|
|
removing these lines causes my control to not even display a single line.
now my listbox is not displaying anything in it.
Future Lies in Present.
Manmohan Bishnoi
|
|
|
|
|
OK. Try this -
Replace
COLORREF rgbBkgnd = ::GetSysColor((lpDIS->itemState & ODS_SELECTED) ?COLOR_HIGHLIGHT : COLOR_WINDOW); with
COLORREF rgbBkgnd = COLOR_WINDOW;
Remove
if( lpDIS->itemState & ODS_FOCUS )
dc.DrawFocusRect(rcItem);
Replace
if( nIndex != (UINT)-1 )
{
COLORREF rgbText = (lpDIS->itemState & ODS_SELECTED) ?::GetSysColor(COLOR_HIGHLIGHTTEXT) : GetItemData(nIndex);
CString str;
GetText(nIndex, str);
dc.SetBkColor(rgbBkgnd);
dc.SetTextColor(rgbText);
dc.TextOut(rcItem.left + 2, rcItem.top + 2, str);
}
with
if( nIndex != (UINT)-1 )
{
COLORREF rgbText = GetItemData(nIndex);
CString str;
GetText(nIndex, str);
dc.SetBkColor(rgbBkgnd);
dc.SetTextColor(rgbText);
dc.TextOut(rcItem.left + 2, rcItem.top + 2, str);
}
|
|
|
|
|
now background goes black for each line added to the listbox.
Future Lies in Present.
Manmohan Bishnoi
|
|
|
|
|
It's solved
just done as you said with some modification:-
REPLACE
COLORREF rgbBkgnd = COLOR_WINDOW;
WITH
COLORREF rgbBkgnd = ::GetSysColor(COLOR_WINDOW);
Thanks SUPERMAN
Future Lies in Present.
Manmohan Bishnoi
|
|
|
|
|
At best, that does not prevent selection, all it attempts to do is not show the selected status...
|
|
|
|
|
Hi again,
I am not here to be a pain, it a OpenGL compiling problem I have with my 3D project. I have went to properties and linked all the libraries and used the #pragma comment (lib, "glut32.lib") and the whole list of error went away then I got 1 last error saying.
fatal error LNK1104: cannot open file 'GLU32.lib, GLUT32.lib, OpenGL32.lib'
Thank you.
Andrew McIntyre
|
|
|
|