|
Hi all.
I want to craete a List Control with small images.
I have to use a CImageList to craete the image list to attach to the CListCtrl.
This little images must be only plain color icons, a green icon, red, yellow, etc. The color is given by RGB.
I'm using this code:
...<br />
CBitmap bitmap;<br />
unsigned char buffer [ 16*16*3];<br />
if( !assignColorToBitmap(reinterpret_cast<unsigned char*>( buffer ), 16, 16, <br />
layerColor.Red(), layerColor.Green(), layerColor.Blue() ) )<br />
{<br />
return FALSE;<br />
}<br />
if( !bitmap.CreateBitmap( 16, 16, 3, sizeof( unsigned char ) * 3, buffer ) )<br />
{<br />
return FALSE;<br />
}<br />
int imageIndex = imageList_.Add( &bitmap, reinterpret_cast<CBitmap*>(NULL) );<br />
if( imageIndex == -1 )<br />
{<br />
return FALSE;<br />
}<br />
if( pList->InsertItem( layerPosition, layerName, imageIndex ) == -1 )<br />
{<br />
return FALSE;<br />
}<br />
...
First i create the buffer for the bitmap color, this done by assignColorToBitmap, i have debugged it and it is right.
Second create a bitmap with the previous buffer with parameters:
width = 16
height = 16
Color plains = 3
Bits per pixel = sizeof( unsigned char ) * 3
Then add the bitmap to the image list, without any mask. And finally insert the item with the corresponding image index.
When i run the dialog all the images are black, when i'm using instead green, red, etc ...
No matter the colors i use i get always a black image.
This code works perfectly if i load and icon instead of craete my own bitmap, but it is not useful in this example because i know onlu at runtime waht colors i have to use for the image list.
Any suggestions?
Thanks
|
|
|
|
|
Have you tried to display your bitmap some other way (like in a CStatic ) just to see if your bitmap definition is wrong or if it is the CImageList that makes trouble ?
~RaGE();
|
|
|
|
|
Hello!
I have 2 questions:
1) How do I declare multidimensional arrays (matrices) in C++??? Can anybody describe it in detail? This is probably a very simple thing, isn´t it?
2) If the first problem is working...can I then declare an array as a member-variable, so that I am able to use this array in my whole program?
Thanks for your help!!!
|
|
|
|
|
Anonymous wrote:
How do I declare multidimensional arrays (matrices) in C++???
Look at this[^], it can help you.
Anonymous wrote:
can I then declare an array as a member-variable
Sure, as any other var.
Marc Soleda.
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
<font color=blue>#define</font> <font color=purple>NULL</font> (<font color=blue>(void</font>*)0)
<font color=blue>class</font> myProgram {
<font color=blue>typedef double</font> ValueType;
<font color=blue>typedef</font> ValueType[][] Matrix; <font color=green>
<font color=blue>private</font>:
Matrix m_matrix; <font color=green>
<font color=blue>public</font>:
myProgram() {
m_matrix = <font color=purple>NULL;</font>
}
myProgram(<font color=blue>int</font> dimX, <font color=blue>int</font> dimY) {
<font color=green>
m_matrix = <font color=blue>new</font> ValueType[dimX][dimY];
<font color=green>
<font color=blue>for</font> (<font color=blue>int</font> i = 0; i < dimX; i++) {
<font color=blue>for</font> (<font color=blue>int</font> j = 0; j < dimY; j++) {
m_matrix[i][j] = <font color=blue>new</font> ValueType();
}
}
}
};
now, you create it like that :
myProgram mp(5, 3); <font color=green>
<font color=green>
<font color=green>
cheers,
TOXCCT >>> GEII power [toxcct][VisualCalc]
-- modified at 10:18 Tuesday 30th August, 2005
|
|
|
|
|
|
Roland Pibinger wrote:
Have you actually compiled that with a C++ compiler? [confused]
what's wrong with my code (except the fact that it is just an example, and certainly should contain much features to be used correctly) ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
-- modified at 2:36 Wednesday 31st August, 2005
|
|
|
|
|
Hi all
I am making an application using property pages. I have used 15 dialog pages.
Now the problem is that when program is executed then only two rows of tabs(8-9 tabs) are displayed and as soon as any tab is clicked all tabs are displayed in three rows.
So please tell me that how can I resolve this problem?
Thanks & regards
|
|
|
|
|
Hi All
I had send a query & waiting for reply by you,
Please reply I am in trouble.
Thanks & Reagards.
Bye
|
|
|
|
|
Hi
I am having a application which I am using to monitor file operations. i have registered my application with the shell using ShChangeNotifyRegister API . If I run my application as a standalone application I am able to get the notifications . But if I run my application as service ShChangeNotifyRegister API is returning Invalid handle value . I m not able to register my application with the shell . Since ReadDirectorychanges is not supported in 98/me i am relying upon ShChangeNotifyRegister . I request you to give me a suggestion .
Vijayaragavan
|
|
|
|
|
hi,
anyone know how to read the VERSION value in the resource file? i am referring to VERSION value that can be found as file version, product version in the windows explorer.
basically, i want to read this value and write to the log file.
any have any idea?
thanks!
|
|
|
|
|
|
How do I mail a file from VC++/MFC application?
I assume there should be a simple function that can implement this...
|
|
|
|
|
|
MAPI Support in MFC[^]
Simple MAPI[^]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
|
How to create a service in vc++ that should run automatically when ever we start the system
|
|
|
|
|
|
|
snprani@yahoo.com wrote:
How to create a service in vc++ that should run automatically when ever we start the system
You will find this link intresting
http://www.codeproject.com/system/#Services[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi all
I want to enumerate all the ports of my PC( e.g. Primary IDE, secondary IDE,COM1, COM 2, LPT1, PS/2 etc.).
How can I achieve this, either by using MFC or any API or any other way.
Please Reply
Thanks & Regards.
|
|
|
|
|
Hello guys out there. I've been doing my project and have some additional functions/codes I added. When I try to compile it returns some error.
The compiling error is shown like this:
--------------------Configuration: WebJudge - Win32 Debug--------------------
Compiling...
MyProjectView.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\MyProject\MyProjectView.cpp(225) : error C2228: left of '.InsertRowTable' must have class/struct/union type
C:\Program Files\Microsoft Visual Studio\MyProjects\MyProject\MyProjectView.cpp(228) : error C2228: left of '.WriteHtmlFile' must have class/struct/union type
Error executing cl.exe.
MyProject.exe - 2 error(s), 0 warning(s)
-----------
From my MyProjectView.cpp (where the error is):
void CMyProjectView::CreateHtmlFile()
{
CPtrArray* pPageInfos = CDatabase::GetInstance()->GetPageInfo();
CHtmlEdit oHtmlEdit();
for (int nIndex = 0; nIndex < pPageInfos->GetSize(); nIndex++)
{
CPageInfo *pPageInfo = (CPageInfo*)pPageInfos->GetAt(nIndex);
oHtmlEdit.InsertRowTable(nIndex, pPageInfo->ToString());
}
oHtmlEdit.WriteHtmlFile("./demo.htm");
}
----------------
Can someone out there, what went wrong with my code? I really don't know how I will solve that.
Thanks and best regards.
With great power comes a great responsibility.
|
|
|
|
|
have u added header for class CHtmlEdit. that might be possible reason.
|
|
|
|
|
Hello
It seems to me you try to create an object of type CHtmlEdit . So, I think You have to remove () from the following statement:
CHtmlEdit oHtmlEdit();
If you omit the paranthesis, an object is created and the default constructor is automatically called.
I hope this solves your problem.
|
|
|
|
|
Thank you guys. No more error now. . Thanks for the quick reply. ciao!
With great power comes a great responsibility.
|
|
|
|