|
oh, that's great. I try to find out this, but not success up to now.
And, can you explain some more, what should I change in my source code now? I tried some thing but not correct.
the structure of pNMLV is
typedef struct tagNMLISTVIEW {
NMHDR hdr;
int iItem;
int iSubItem;
UINT uNewState;
UINT uOldState;
UINT uChanged;
POINT ptAction;
LPARAM lParam;
} NMLISTVIEW, *LPNMLISTVIEW;
which member should I take and how to compare with LVIS_FOCUSED, LVIS_SELECTED?
In fact, I tried this
int x = pNMLV->uChanged;
if (x == ){
} else if (x == LVIS_FOCUSED){
} else if (x == LVIS_SELECTED){
}
but it's always be LVIS_FOCUSED|LVIS_SELECTED, so it always draws and draws
|
|
|
|
|
tataxin wrote: int x = pNMLV->uChanged;
Look at the two "state" members.
tataxin wrote: if (x == ){
You have to compare bits here.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I solved it,
The final source code is;
if ((pNMLV->uChanged & LVIF_STATE) != LVIF_STATE)
return;
if (pNMLV->uOldState & LVIS_SELECTED)
{
}
else if (pNMLV->uNewState & LVIS_SELECTED)
{
}
It works, great!!!!!
Thank you for your suggestion, DavidCrow,
|
|
|
|
|
GetDIBits is returning ERROR_INVALID_PARAMETER. How to find out which parameter is incorrect. Is there a way?
Regards
|
|
|
|
|
Maybe posting code...
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
|
|
|
|
|
|
I read that article but still i am not able to find the bug in my code. here is my code
CDC dcMem;
CBitmap bmpMem;
CBitmap *oldbm = NULL;
CDC dc;
HDC hdc = ::GetDC(m_pOcxItem->m_hWnd);
dc.Attach(hdc);
LPVOID lpvBits = NUL
// save the device context
int nHandle = ::SaveDC(hDC);
// create a memory device context for offscreen drawing
if (!dcMem.CreateCompatibleDC(&dc))
_com_issue_error(HRESULT_FROM_WIN32(::GetLastError()));
if (!bmpMem.CreateCompatibleBitmap(&dc, rect.Width(), rect.Height()))
_com_issue_error(HRESULT_FROM_WIN32(::GetLastError()));
oldbm = dcMem.SelectObject(&bmpMem);
dcMem.SelectObject((HBRUSH)GetStockObject(WHITE_BRUSH));
// delesect the device dependent bitmap from the offscreen device context (must be out when GetDIBits is called)
dcMem.SelectObject(oldbm);
// get the header structure for a device independent bitmap (DIB) setup with the biggest possible palette
BITMAPINFO *bmi = (BITMAPINFO *) _alloca(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
memset(&bmi->bmiHeader, 0, sizeof(BITMAPINFOHEADER));
bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
// query for the bitmap information (NULL does a query)
int scanLineCount = GetDIBits(dcMem, bmpMem, 0, rect.Height(), NULL, bmi, DIB_RGB_COLORS);
if (!scanLineCount)
_com_issue_error(HRESULT_FROM_WIN32(::GetLastError()));
//here this is giving one of the parameter is incorrect
With the same code my another bitmap is getting printed with black background.
Any help is appreciated.
|
|
|
|
|
What happens if you change two lines of your code to this:
dcMem.CreateCompatibleDC(GetDC())
bmpMem.CreateCompatibleBitmap(GetDC(), rect.Width(), rect.Height()))
|
|
|
|
|
But GetDC() returns a HWND parameter where as CreateCompabileDC expect CDC* value
|
|
|
|
|
Are you sure? GetDC()//it returns CDC*
|
|
|
|
|
No GetDC returns HDC whereas createcompatable takes CDC pointer
|
|
|
|
|
No its not ture.
CDC dc*;
dc=GetDC();
HDC hdc;
hdc=::GetDC(HWND);
|
|
|
|
|
I made small modifications to your code and passed my window hwnd but the result is same. one of the parameter is incorrect
|
|
|
|
|
Can you tell me what do you want to do?
|
|
|
|
|
I know this is not the forum. I am printing activex controls. I was not able to print them. Last week i posted the problem in com forum. I found the solution. we have 4 legacy activex controls. out of them i am able to print two of them. One is raising one of the parameter is incorrect and another is printing with black background image. This is my problem.
|
|
|
|
|
Is it possible for you to print your bitmaps without any activex controls?
|
|
|
|
|
i found in the msdn GetDIBits returns zero if the header information is incorrect
BITMAPINFO *bmi = (BITMAPINFO *) _alloca(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
memset(&bmi->bmiHeader, 0, sizeof(BITMAPINFOHEADER));
bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
int scanLineCount = GetDIBits(dcMem, bmpMem, 0, rect.Height(), NULL, bmi, DIB_RGB_COLORS);
the value of bmi->bmiHeader.biSize is 40 while debugging.
what i have to do to pass the correct header information
|
|
|
|
|
|
Thanks for the article. But that didn't help. My code is working well for two activex controls but for another it is returning invalid argument(GetDIBits). I am assuming that i have to do something in the activex control. What i have to do in that. That i don't know. If any one knows please help me.
|
|
|
|
|
Hi,
I have vector<string>
and I want to have char**.
Is there any elegant way?
|
|
|
|
|
a vector of what is it ?
and why do you want to regress back to char** ?
|
|
|
|
|
Oh, Sorry for incomplete information.
I have a vector of strings
e.q. vector<<string>>
|
|
|
|
|
you didn't replied the second part of my question :
"and why do you want to regress back to char** ?"
BTW, you could do something like this, but I seriously doubt about the need of this:
std::vector<std::string> v;
size_t n = v.size();
char** str_arr = ::new char*[n];
int i = 0;
for (vector<string>::iterator it = v.begin(); it != v.end(); it++, i++) {
str_arr[i] = ::new char[(it->length())+1];
::strcpy(str_arr[i], it->c_str());
}
of course, don't forget to free all that memory allocated, otherwise, you're leading into memory leaks...
modified on Thursday, May 22, 2008 9:30 AM
|
|
|
|
|
I am using a legacy API which needs char** as [in] parameter.
Thanks for suggesting this solution.
I guess there is one typo
<br />
char** str_arr = new char*[n];<br />
Is there any other quick soln exists?
|
|
|
|
|
vikrams wrote: I guess there is one typo
you're totally right, I fixed it in my previous post.
vikrams wrote: Is there any other quick soln exists?
I sorted this one from the top of my head, but i doubt you'll find better/shorter solutions for this.
BTW, check that you're API needs or not a trailing nul ('\0') character at the end of the char* array (the one called str_arr ). if so, you'll have to change my code. if not, it's probably expecting an integer with the array size; that's what n is storing.
|
|
|
|