|
And what about the budget?
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
|
|
|
|
|
CPallini wrote: And what about the budget?
For you free.
|
|
|
|
|
Hamid. wrote: For you free
OK.
Done.
He can download it on the website
www.cpallini.freeproducts.com
(it maybe down for a while due to funds shortage... )
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 don't free!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Sounds like one of those "urgent" questions to me.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Anyone know of a good tutorial/code sample that demos how to make a proper popup window, something like you'd use to make your own menus, or drop-down for a combo-box like control? I'm having some issues trying to do this, and I'd like to find something that does it correctly that I can look at.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
This one is about ComboBox[^] but why so secretive?
Jim Crafton wrote: I'm having some issues trying to do this
Issues like? It's difficult to find anything specifically about your secret issues.
led mike
|
|
|
|
|
Yeah that was a bit vague I suppose. But I've got to be careful, in case they see me...
Anyhow it was problems related to activation - which window was getting highlighted (or not). Turns out I was forgetting to forward the msg along to the default wndproc. I think I have it sort of fixed now.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Assuming MFC...
Attempt #1: You can CreateEx() with WS_POPUP style but that will deactivate your app while the popup is up and your popup window will show up in the taskbar.
Attempt #2: You can give it an extended style of WS_EX_TOOLWINDOW to prevent the taskbar entry but that doesn't solve the deactivated application problem.
The solution is to avoid WS_POPUP and use CreateEx() with an extended style of WS_EX_TOOLWINDOW, style of WS_CHILD, and make the parent the desktop window.
There are other issues to contend with but that will get you a window that can extend beyond the window of your application.
Hope that helps.
|
|
|
|
|
Thanks for the pointers! Yes that helped.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
I have successfully used SetDIBitsToDevice to copy a bitmap to the current job's window on the screen; but I cannot find a function GetDIBitsFromDevice. Please how could I copy the whole of the user area (i.e. not the edging) of the current job's window onto a bitmap?
|
|
|
|
|
Anthony Appleyard wrote: Please how could I copy the whole of the user area (i.e. not the edging) of the current job's window onto a bitmap?
If you are using MFC, try something like:
CDC dc;
HDC hdc = ::GetDC(wnd->m_hWnd);
dc.Attach(hdc);
CDC memDC;
memDC.CreateCompatibleDC(&dc);
CRect r;
wnd->GetClientRect(&r);
CSize sz(r.Width(), r.Height());
CBitmap bm;
bm.CreateCompatibleBitmap(&dc, sz.cx, sz.cy);
CBitmap *oldbm = memDC.SelectObject(&bm);
memDC.BitBlt(0, 0, sz.cx, sz.cy, &dc, 0, 0, SRCCOPY);
"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
|
|
|
|
|
Thanks; but I want to copy the screen into a bitmap specified by a BITMAPINFO and an array of bytes, using the plain old Windows API functions.
|
|
|
|
|
Anthony Appleyard wrote: copy the screen into a bitmap specified by a BITMAPINFO and an array of bytes, using the plain old Windows API functions
RECT rct;
HWND wnd = ::GetDesktopWindow();
::GetWindowRect(wnd,&rct);
HDC hDC = ::GetDC(NULL);
int iWidth = rct.right - rct.left;
int iHeight = rct.bottom - rct.top;
BITMAPINFOHEADER BMI;
BMI.biSize = sizeof(BITMAPINFOHEADER);
BMI.biWidth = iWidth;
BMI.biHeight = -iHeight;
BMI.biPlanes = 1;
BMI.biBitCount = 32;
BMI.biCompression = BI_RGB;
BMI.biSizeImage = 0;
BMI.biXPelsPerMeter = 0;
BMI.biYPelsPerMeter = 0;
BMI.biClrUsed = 0;
BMI.biClrImportant = 0;
BYTE *pSrcBits;
HBITMAP hbmSrc = ::CreateDIBSection(hDC, (BITMAPINFO *)&BMI,DIB_RGB_COLORS, (void **)&pSrcBits,NULL,0);
HDC dc = ::CreateCompatibleDC(NULL);
HBITMAP hbm = (HBITMAP)::SelectObject(dc, hbmSrc);
::SetStretchBltMode(dc, HALFTONE);
::BitBlt(dc,0,0,iWidth,iHeight,hDC,0,0,SRCCOPY);
HBITMAP hOld = (HBITMAP)::SelectObject(dc, hbm);
::SelectObject(dc,hOld);
::ReleaseDC(wnd,hDC);
::DeleteDC(dc);
::DeleteObject(hbmSrc);
Best Wishes,
-David Delaune
|
|
|
|
|
|
|
void main()
{
char *buffer = new char[];
int n, a=5, b=3;
n = sprintf (buffer, "%d plus %d is %d", a, b, a+b);
printf ("[%s] is a %d char long string\n",buffer,n);
delete [] buffer; // THIS LINE THROWS an error
}
I need to have a dynamic array as shown, if i try to clean up the array, throws an exception. Any help will be great. Has to be in C++ only, no MFC please.
I am using visual Studio 6.0.
Thanks,
Saleem
|
|
|
|
|
what about allocating the array with a valid size ?
|
|
|
|
|
The issue here is i do not know the size of the array.
It has to be dynamic.
|
|
|
|
|
Md Saleem Navalur wrote: char *buffer = new char[];
Based on your example, you'd need, at most, 41 bytes. I wouldn't bother Windows' memory manager for such a minuscule amount.
"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
|
|
|
|
|
You need to allocate a buffer having at least as many characters as string length plus 1 (string terminator). Since you don't know a priori what is the string length, then you may allocate a relatively large buffer. For instance:
char * buffer = new char[256];
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
|
|
|
|
|
char *buffer = new char[256]...
this can also be declared as
char buffer[1024]....
But the issue here is i do not know the size of the array.
It has to be dynamic.
|
|
|
|
|
Md Saleem Navalur wrote: But the issue here is i do not know the size of the array.
It has to be dynamic.
Then you have a design decision to make. If you only need a few thousand bytes, create a stack-based variable. Otherwise, if the difference between the least amount required and the max amount required is only a few hundred KB, then create a heap-based variable using the max amount. Lastly, employ the use of a string , vector , or similar data structure.
"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
|
|
|
|
|
char *buffer = new char[];
int n, a=5, b=3;
n = sprintf (buffer, "%d plus %d is %d", a, b, a+b);
printf ("[%s] is a %d char long string\n",buffer,n);
Md Saleem Navalur wrote: But the issue here is i do not know the size of the array.
It has to be dynamic.
Actually the issue is that you haven't allocated any memory prior to calling sprintf . Your call to sprintf is overrunning the buffer since the buffer has no size. sprintf doesn't allocate it for you - you must do that prior to calling the function. After you've overrun the buffer, all bets are off on anything else working correctly.
The "new" sprintf_s functions accept a length-of-buffer indicator to avoid an overrun like this.
Judy
|
|
|
|
|
It would probably be better to go with 257 bytes, just in case.
|
|
|
|