|
I don't think the tree view supports that many bitmaps per item.
You could combine the CustomStateBitmap and the ItemBitmap as a single bitmap, something like this:
+----------------+
| +----+ +----+ |
| | CS | | IB | |
| +----+ +----+ |
+----------------+ Visually, the single bitmap looks like two bitmaps with a clear area between. Of course, this means you would have to have a set of bitmaps, one for each possible combination of "custom state" and "item".
Gary R. Wheeler
|
|
|
|
|
Hello,
Is there a simple way to override the default selection format indication for a CListCtrl---or stop the selection from drawing? The default behavior is for the selected CListCtrl (report) item to be drawn with a dark system color while inversing the text to white. I would like to use an alternative drawing scheme to indicate that the item(s) is selected. I would rather not choose to draw the entire control myself.
thanks!
JennyP
|
|
|
|
|
It's possible to do it using Custom Draw (without drawing the whole control). Take a look at "NM_CUSTOMDRAW (list view)" in the MSDN index.
Chris Richardson
|
|
|
|
|
Why do my drop down list want to automatically scroll back up when I'm trying to scroll down?
Is there some option that I have set to do this?
Thanks for the help!
|
|
|
|
|
Thats sounds very strange...did you override OnVScroll() with SetCurSel(0) inside the fucntion...?
jimNLX wrote:
Is there some option that I have set to do this?
Not that I know of
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
This is all that I did...
CComboBox *pSelBox = (CComboBox *) GetDlgItem(IDC_SEL);
pSelBox->SetCurSel(-1);
pSelBox->SetItemHeight(2,40);
pSelBox->SetDroppedWidth(425);
Then I filled the list with a loop that adds strings..
pSelBox->AddString(desc[i]);
How can I get this thing to stop jumping around?
|
|
|
|
|
If you open a catalaog in ADOx, then a table, should you close them after you are done? THis wont close the database will it? (and destroy my member database variable )
Appreciate your help,
ns
|
|
|
|
|
Dont know...but it should not be difficult to test.
|
|
|
|
|
When you refresh the catalog, the catalog is updated. You don't need to close for make that...
Regards...
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Hello,
I am trying to replace or remove strA with in strB. The problem is that I want to start removing/replacing after a index.. Is there a way to do this??
Thanks!
|
|
|
|
|
If you mean replace after a certain index in strB, then why dont you determine what the substring in strB is with the index, and create substring C and use that to replace.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
The string that needs to be modified is never the same.. I am trying to remove \par from a rich text string but only after a specific point.. here's the example..
String a;
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Arial;}}
{\colortbl ;\red255\green0\blue0;}
\viewkind4\uc1\pard\cf1\fs17 Hello this is a test
\par Hello this is a snd test
\par Woot
\par \cf0
\par }
String b;
Woot
String a after the remove;
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Arial;}}
{\colortbl ;\red255\green0\blue0;}
\viewkind4\uc1\pard\cf1\fs17 Hello this is a test
\par Hello this is a snd test
\par Woot
\cf0
}
I want to remove the 2 "\par "'s from string a.. but only after "Woot".
Note string a is not allways the same.. some times it has the color tag at the end and some times it doesn't.
|
|
|
|
|
Not tested, but:
void ReplaceAfterIndex(int nIndex, const CString& strOld, const CString& strNew, CString& rstrTarget)
{
while ( (nIndex = rstrTarget.Find(strOld, nIndex)) >= 0 )
{
CString strTemp;
if ( nIndex > 0)
strTemp = rstrTarget.Left(nIndex);
strTemp += strNew;
if ( nIndex + strOld.GetLength() < rstrTarget.Length()-1 )
strTemp += rstrTarget.Mid(nIndex, strOld.GetLength());
nIndex += strOld.GetLength();
}
}
Shog9
------
And on the pedestal, these words appear:
"My name is Ozymandias, King of Kings,
Look on my Works, ye Mighty, and despair!"
Nothing beside remains.
|
|
|
|
|
Give a specific example.
Kuphryn
|
|
|
|
|
Hi,
Any similar problems and/or solutions would be gratefully received!
I've got a setup (msi) made with Installer 1.1 that comes with VS6.
It works like a charm if I log in and install as administrator, but after installation when I try logging in as another user no start menu items (program group, or icons) appear in the start menu.
As well as that, on a client's machine, when other users (IE not Administrator) try our program it completely flakes out; they keep getting 'unsupported operation' when running through the program. We use both ADO as well as flexgrid, but MDAC 2.6 and the FlexGrid files are all installed.
I should note all the machines are Win2k sp3 (the client's are brand new).
Cheers,
Paul
|
|
|
|
|
Hello,
I think some of you problems could be in the install program.. When the install package creates the shortcuts all short cuts should be put into the "All Users" profile instead of the "Administrator" or currently logged in profile. 2nd.. If your install package needs to write to the system32 directory you will have to run the install as a admin (no way around it) its the same with all other apps..
Hope this helps
|
|
|
|
|
Hi, I'm sorry but this might be a long description. It's about the only way I can explain what is happening.
I've been trying to crop a piece from one bmp file to put into another with an MFC app. The thing is I'm really new to programming, and don't know how to do very much. I've tried a few examples on here, which I didn't get to work because they all seem to use the sceen as a display. I need this to be done behind the scene. I've been trying to learn about DC's but again all the examples I've run into are for the monitor. haha so you see my dilema.
Anyway, what I've come up with is reading in the bmp using a CFile and malloc some memory for it. Then I read out the BITMAPFILEHEADER, and BITMAPINFO. Which I write to the new file. Then from my understanding, the data that follows should be the actual pixels for the image. So to test this I reverse the bits and then write the reversed bits into the new bmp. In theory this should result in an upside down image. It does but, the colors are totally distorted. This is what is confusing me. Am I missing the color palette? Or am I not reading the RGBQUAD correctly? Any help with this would really be appreciated.
Here's my code, maybe you can see where my problem is. Thanks.
<br />
<br />
CFile dibFile(_T("BITMAP1.bmp"), CFile::modeRead);<br />
<br />
<br />
<br />
<br />
BITMAPFILEHEADER bmpFileHead;<br />
<br />
<br />
if(!dibFile.Read((void*)&bmpFileHead, sizeof(BITMAPFILEHEADER)))<br />
AfxMessageBox("Read failed.");<br />
<br />
<br />
<br />
if(bmpFileHead.bfType == ((WORD) ('M' << 8) | 'B'))<br />
{<br />
<br />
DWORD fileLength = dibFile.GetLength();<br />
<br />
<br />
DWORD size = fileLength - sizeof(BITMAPFILEHEADER);<br />
<br />
<br />
BYTE* pDib = (BYTE*)malloc(size);<br />
if(!pDib)<br />
AfxMessageBox("Allocation failed");<br />
<br />
BYTE* pTest = (BYTE*)malloc(size);<br />
if(!pTest)<br />
AfxMessageBox("Allocation failed");<br />
<br />
<br />
dibFile.Read((void*)pDib, size);<br />
dibFile.Close();<br />
<br />
<br />
<br />
BITMAPINFO* pBmpInfo = (BITMAPINFO*)pDib;<br />
<br />
<br />
<br />
BITMAPINFOHEADER* pBmpInfoHead = (BITMAPINFOHEADER*) pDib;<br />
<br />
<br />
<br />
RGBQUAD* pRGB = (RGBQUAD*)(pDib + pBmpInfoHead->biSize);<br />
<br />
<br />
<br />
int s = 0;<br />
for(unsigned g = 44;g < size;g++)<br />
{<br />
pTest[s] = pDib[g];<br />
s++;<br />
}<br />
CFile wFile(_T("test.bmp"), CFile::modeWrite | CFile::modeCreate | CFile::typeBinary);<br />
<br />
wFile.Write((void*)&bmpFileHead, sizeof(BITMAPFILEHEADER));<br />
<br />
wFile.Write((void*)pDib, sizeof(BITMAPINFO));<br />
<br />
wFile.Write((void*)pTest, size);<br />
<br />
wFile.Close();<br />
<br />
<br />
free(pTest);<br />
free(pDib);<br />
}<br />
|
|
|
|
|
For an paletted bitmap, you have to use the CPalette classes. There are articles around her and on MSDN do to that.
|
|
|
|
|
What you need to do is use a MemoryDC. A memory DC is simply located in memory. You will need to use a DC because that is how you manipulate bitmaps in windows.
First load the image into a CBitmap object with ::LoadImage(...).
Then you will need to create a MemoryDC, however in order to create a memory DC, you first need to have a DC to a window in order to properly set the color bits. If you are going to display this to a particular window, then use GetDC(hwnd) for the window that you will use, or you can use GetDC(NULL) to get the Desktop DC.
if you have a handle to your window hwnd, this is how you would create your memory DC and associate the bitmap with your DC.
<br />
CWindowDC dc(hwnd);<br />
CDC memDC;<br />
memDC.CreateCompatibleDC(dc);<br />
<br />
CBitmap bmp;<br />
bmp.LoadBitmap("C:\\winnt\\bubbles.bmp");<br />
<br />
memDC.SelectObject(bmp);<br />
At this point you will have your bitmap selected into a memory DC and you can start manipulating it. If you want to paste all or just a portion of this bitmap to a window then you can use the BitBlt function of the CDC class.
If you want to create another bitmap that is a cropped portion of your original image, you will first need to create a second Memory DC ans select a bitmap into it that is the size that you desire.
<br />
CDC memCropDC;<br />
memCropDC.CreateCompatibleDC(memDC);<br />
BITMAP bm;<br />
bmp.GetBitmap(&bm);<br />
bm.bmWidth = bm.bmWidth / 2;<br />
<br />
CBitmap bmpCrop;<br />
bmpCrop.CreateBitmapIndirect(&bm);<br />
memCropDC.SelectObject(bmpCrop);<br />
Now you can use bit blt to copy a small portion of the original bitmap into the new smaller cropped image. Here are three examples of how you can copy the bitmap.
<br />
memCropDC.BitBlt(0, 0, bm.bmWidth, bm.bmheight, &memDC, 0, 0, SRCCOPY);<br />
memCropDC.BitBlt(0, 0, bm.bmWidth, bm.bmheight, &memDC, bm.bmWidth, 0, SRCCOPY);<br />
memCropDC.BitBlt(0, 0, bm.bmWidth, bm.bmheight, &memDC, bm.bmWidth / 2, 0, SRCCOPY);<br />
If you look on code project there should be a few examples of how to manipulate bitmaps with memory DCs.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Hey thanks for the quick response. I really appreciate it. I had tried similar code to this. But I couldn't figure out how to get the memDC back into a file. I'm thinking I'll have to use ::CreateFile() and ::WriteFile(). Anyway, thanks again.
|
|
|
|
|
I did a quick search (Christian Graus would be so proud!) before posting, to see if anyone had a similar problem as me, and looks like Mike did!
What I'm doing is loading a bitmap from a file, then creating CBitmaps from parts of the file, then using them on buttons. The bitmap file I'm looking is a long strip of images (kind of like an array of images).
It's probably easier to understand if you read the code:
xOffset is the index of the image I want (kBitmapHeight/Wdith are 16 (the size of each image)).
CBitmap temp;
GetBitmapFromResource("c:\\mybitmap.bmp", 0, 0, temp);
m_cMyButton.SetBitmap(temp);
GetBitmapFromResource("c:\\mybitmap.bmp", 1, 0, temp);
m_cMyButton2.SetBitmap(temp);
/
*static*/ bool GetBitmapFromResource(const CString& filename, const int xOffset, const int yOffset, CBitmap &bitmap)
{
CBitmap sourceCBitmap;
bool status = true;
HBITMAP hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), filename, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE);
status = sourceCBitmap.Attach(hBmp);
if (!status) {
TRACE0("Failure to load bitmap.\n");
return false;
}
BITMAP sourceBitmap;
sourceCBitmap.GetBitmap(&sourceBitmap);
sourceBitmap.bmHeight = kBitmapHeight;
sourceBitmap.bmWidth = kBitmapWidth;
if (bitmap.m_hObject != NULL) {
bitmap.Detach();
}
status = (bitmap.CreateBitmapIndirect(&sourceBitmap) != 0);
if (!status) {
TRACE0("Failure to create indirect bitmap for source.\n");
return false;
}
CDC sourceCDC;
status = (sourceCDC.CreateCompatibleDC(NULL) != 0 );
if (status) {
void* gdiObject1 = sourceCDC.SelectObject(sourceCBitmap);
CDC targetCDC;
status = (targetCDC.CreateCompatibleDC(NULL) != 0);
if (status) {
void* gdiObject2 = targetCDC.SelectObject(bitmap);
status = (targetCDC.BitBlt(0, 0, kBitmapWidth, kBitmapHeight, &sourceCDC,
xOffset * kBitmapWidth, yOffset * kBitmapHeight, SRCCOPY) != 0);
targetCDC.SelectObject(gdiObject2);
} else {
TRACE0("Failure to create DC for target.\n");
}
sourceCDC.SelectObject(gdiObject1);
} else {
TRACE0("Failure to create DC for source.\n");
}
return status;
}
As you can see, my code is similar to yours.
After calling this with xOffset as 0 and 1, the image of the button is the same (the first image in the file).
However, if I add the bitmap as a resource of my exe, and then load it with
status = (sourceCBitmap.LoadBitmap(resourceID) != 0);
instead of
HBITMAP hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), filename, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE);<br />
status = sourceCBitmap.Attach(hBmp);
then everything works (the first button is used for xOffset = 0, the second for xOffset = 1, etc).
The problem is that the bitmap file I'm loading can't be an internal resource: it has to be an external file.
Any ideas on what I need to do to fix this?? It's been bugging me!!
Thanks very much!
|
|
|
|
|
I've got an app that I'm trying to create an installation for but am confused with what DLL's to use/register. Does every DLL have to be registered? I mean if I replace a DLL with a newer version does the new one have to be registered and/or do I have to unregister the old one before replacing it? I'm having problems.
My development machine has Win2K on it but if I deliver the Windows 2000 versions of wsock32.dll (winsock) and ws2_32.dll on a Win98 system, either my application or some other Winsock application won't work.
Where do I get dlls that are either a) the latest and greatest for that operating system or b) are 100% compatible for all Win32 operating systems and c) does that even exist?
I know my setup program can be modified to detect OS and I can configure it so that it will install the proper DLLs per operating system but where do I get them? Is it proper procedure to just copy them from a Win98 machine, a Win2000 machine and a WinME machine? And, if I do that am I asking for trouble later on?
Any help, please?
|
|
|
|
|
A trick:
if you see the dll file properties, in the tab version you can see in the item name several items, if in the list of thouse, you see a item named OleSelfRegister, you MUST to register the file, if you don't see that item, you only need to copy the file, without register it...;)
Cheers, and good instalation
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Thanks. In what application, Explorer?
|
|
|
|
|
winsocks is distributed by MS as a zip-OS dependent package. Can't remember the exact url right now.
Now that XP is out, you should also pay attention to what's known as merge modules (.msm files). Those are packages redistributed by MS (see MSDEV.NET cd), which are part of the final .msi setup, which is supposed to be now the only way to properly install software on XP+ OSes.
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|