|
Hi,
I download a '.bmp' file through internet and save bits in the heap like char*, can I create CBitmap without save file to disk.
|
|
|
|
|
Is CBitmap really what you want? CBitmaps are device-depentent bitmaps (DDB)
while a .bmp is device independent bitmap (DIB).
You can convert bitmaps from whatever type to whatever other type, but you
need to specify what type you want the resulting bitmap to be.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I don't know : )
but i fix it, i save file on disk and read it from there. Furst i try to separate data from header in .bmp file, because i saw one function which draw on dc directly from data bits of .bmp, but something get wrong and save it on the disk.
work fine now.
|
|
|
|
|
hi all... i am using ICC_BAR_CLASSES to initialize controls to create toolbar....
but i am getting one error
[linker error] undefined reference to `InitCommonControlsEx@4'
code creating problem is...
//-----------------------------------
INITCOMMONCONTROLSEX InitCtrlEx;
InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
InitCtrlEx.dwICC = ICC_BAR_CLASSES;
InitCommonControlsEx(&InitCtrlEx);
//-----------------------------------
As structure INITCOMMONCONTROLSEX and function InitCommonControlsEx(..) are defined in commctrl.h i included this in my program.....earlier INITCOMMONCONTROLSEX this was also giving same error then i opened the header file commctrl.h and there i found these lines
//--------------------------------------
#if (_WIN32_IE >= 0x0300)
typedef struct tagINITCOMMONCONTROLSEX {
DWORD dwSize;
DWORD dwICC;
} INITCOMMONCONTROLSEX,*LPINITCOMMONCONTROLSEX;
#endif
//--------------------------------------
#if (_WIN32_IE >= 0x0300)
BOOL WINAPI InitCommonControlsEx(LPINITCOMMONCONTROLSEX);
#endif
//--------------------------------------
so in my program before header file in included
#ifdef _WIN32_IE
#undef
#endif
#define _WIN32_IE 0x501
and also
#ifdef _WIN32_WINNT
#undef
#endif
#define _WIN32_WINNT 0x501
now INITCOMMONCONTROLSEX is working fine... but i am getting error with InitCommonControlsEx(...)
error is
[linker error] undefined reference to `InitCommonControlsEx@4'
i am using Dev-C++ 4.9.9.2 compiler
can someone suggest me something...
thanx in advance....
bye have a nice day.....
|
|
|
|
|
hey its working now...
what u need to do is just link library....
in case of devc++ ists libcomctrl32.a
bye have a nice day.....
|
|
|
|
|
Dear All
Hi
In one heavy project which creates 23 threads in one process, sometimes programs exits without any exception.
We set drwtsn32 to catch any exception but we find that no exception occurs.
program is executed in Windows 2000 service pack 5 OS.
some log files shows that before program exits, some time critical threads report time out, and then program exits and all thread destroyed.
If exception is the reason of such problem then dr watson should log it but no exception is reported.
If you know what is the reason of this problem please let me know.
Regards
Monhi
|
|
|
|
|
I use transparentblt to display an overlay color image?
::TransparentBlt(pDC->GetSafeHdc(),upperLeftX,
upperLeftY, width, height,
paintMemory.GetSafeHdc(),0,0,width,height,RGB(0,0,0)) ;
where paintMemory is contains color pixels using method call
paintMemory.SetPixel(CPoint(x,y),RGB(255,0,0);
the color image is display correctly. How can I clear this overlay?
|
|
|
|
|
gurucplusplus wrote: How can I clear this overlay?
Draw something else over the top of it?
I'm curious why you use the CDC class but you go through the extra trouble
of extracting the HDCs from the CDC objects to call a GDI API directly instead of
using the CDC method CDC::TrasparentBlt()...?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am not sure what you mean? Can you give me
an example?
|
|
|
|
|
It depends on what you mean by "clear this overlay"
For the TransparentBlt call...
::TransparentBlt(pDC->GetSafeHdc(),upperLeftX,upperLeftY, width, height,
paintMemory.GetSafeHdc(),0,0,width,height,RGB(0,0,0)) ;
could be
pDC->TransparentBlt(upperLeftX, upperLeftY, width, height,
&paintMemory,0,0,width,height,RGB(0,0,0)) ;
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
For my application, I display paintMemory using ::transparentBlt in red using paintMemory.SetPixel(point(x,y),RGB(255,0,0)) But I don't know how to clear this paintMemory to transparency by reseting paintMemory.SetPixel(point(x,y),RGB(0,0,0)).
I have an greyimage display in the background and would like to paint an color image using paintMemory to paint a color on top of this image without destructing the content of the greyimage. Once I draw complete I would like to see this greyimage background back by clearing the painMemory by setting color of paintMemory pixel back to color RGB(0,0,0).
But It doesn't work.
|
|
|
|
|
gurucplusplus wrote: But I don't know how to clear this paintMemory to transparency by reseting paintMemory.SetPixel(point(x,y),RGB(0,0,0)).
paintMemory is a memory DC, correct?
An easier and possibly faster way to clear the entire bitmap associated with the DC is something like:
paintMemory.FillSolidRect(0, 0, BitmapWidth, BitmapHeight(), RGB(0, 0, 0));
What's not working?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
paintMemory is a memory DC.
Let do an example. I implement the following:
painMemory.FillSolidRect(0,0,BitmapWidth,BitmapHeight(),RGB(255,0,0));
::TransparentBlt(pDC->GetSafeHdc(),m_upperLeftX, 0,BitmapWidth,0,BitmapHeight,
paintMemory.GetSafeHdc(),0,0,BitmapWidth,BitmapHeight,RGB(0,0,0));
// At this point I see the overlay image is red.
// Then next is try to clear this overlay painMemory from red to RGB(0,0,0)
painMemory.FillSolidRect(0,0,BitmapWidth,BitmapHeight(),RGB(0,0,0));
::TransparentBlt(pDC->GetSafeHdc(),m_upperLeftX, 0,BitmapWidth,0,BitmapHeight,
paintMemory.GetSafeHdc(),0,0,BitmapWidth,BitmapHeight,RGB(0,0,0));
// At this point I still see the overly image is red instead of black
I need solution for this ASAP. Thanks
|
|
|
|
|
Are you drawing to the screen? Is this code in a WM_PAINT message handler (OnPaint())?
You can't erase - you need to redraw what was "underneath" the red.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes, I draw to the screen. I add WM_PAINT message handler OnPaint() as you suggested as shown
CMyView::OnPaint()
{
CPaintDC dc(this); // device context for painting
OnPrepareDC(&dc);
OnDraw(&dc);
}
And OnDraw(CDC pDC) I have GDI method to draw image on screen that always works.
After I implement OnPaint(). It still doesn't redraw image underneath the red.
Please Help!
|
|
|
|
|
I didn't suggest anything - I was asking.
You don't need an OnPaint override in a view since there's OnDraw().
You do, however, need to draw whatever you want to appear.
You can't draw something to the screen and then erase it, expecting to see
what was underneath it.
It's up to you to redraw the window without the overlay.
You can force a window to repaint by invalidating a portion (or all)
of the window with one of the Invalidate___() methods/APIs.
That will cause your OnDraw() to be called, where you can draw
whatever you want to appear on the window.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I want to convert a unsigned char string to other character set char string.
In UNIX,there have iconv() such functions to do the task,but how to do it in Windows,Especially using VC?
Thanks.
GOOD LUCK.
|
|
|
|
|
|
Because that,I want to output any language not only English.
When I output English,it works well but if the string contains another language,like Chinese,it does not work well.The output is wrong.
Thanks.
|
|
|
|
|
I'm timing a threading utility that pushes a bunch of work to the thread pool, executes the work, and then figures out how much time it has taken overall. The concept is really simple. That said, when I run the tests regularly in release mode with /O2 enabled, the time either takes 0.25s or 0.33s, and it randomly alternates between the two. Now, if I add a printf() statement right when the thread pool is shutting down, printing the number of work units that each thread has completed, the timing result is always 0.25s -- and by always, I mean 100%. It will never be 0.33s. In fact, I tried replacing this printf() statement with one that simply prints out "WTF?", and the result is the same (the time always ends up being 0.25s and never 0.33s). This makes me think that there is something with console operations that is changing the innards of my timing, however, I have no clue what it is.
For reference, I am using Visual C++ 2005, and QueryPerformanceCounter() / GetTickCount() to do my timing (I've used both, and they both give me these kinds of different results).
Anyone know what's going on?
EDIT: I forgot to mention one important thing. Here is how my timing works:
#1: Initialize thread pool
#2: Get count of start time
#3: Queue and process work
#4: Get count of end time
#5: Release thread pool
Now, we can truly understand the hilarity of these results, as the printf() statement, within the release of the thread pool, is not even within the count of the start and end! It's as if something I am doing in the future is changing the result of what is happening now.
|
|
|
|
|
Maybe overwritting your stack at some point ?
Put some Sleep calls to make the execution times longer see if they follow the time you set
|
|
|
|
|
I will give this a try.
Thanks.
|
|
|
|
|
Hi,
I believe when a thread does not have any sychronization objects associated with it, the OS kernel will yield and pre-empt the thread in a semi-random way, based on a priority-driven, preemptive scheduling algorithm. However once a thread has created a synchronization object the OS kernel begins to internally use this object as a reference point for yeilding process time. So by simply having created a synchronization object within a thread, the quantum timeslices should indeed become more uniform.
http://msdn2.microsoft.com/en-us/library/ms686364.aspx[^]
Maybe when your application is opening STD_INPUT_HANDLE or STD_OUTPUT_HANDLE an internal synchronization object is being created and causing the uniform quantum slices. This is just purely a guess.
It should also be noted that when using QueryPerformanceCounter on a multiprocessor computer that in order to retrieve the most accurate timestamp you should set the threads affinity mask to a single processor using SetThreadAffinityMask.
Best Wishes,
-Randor (David Delaune)
|
|
|
|
|
Thanks for the reply. Your explanation sounds plausible, although there doesn't seem like a way for me to confirm this. I am pretty sure this has nothing to do with multiprocessors and QueryPerformanceCounter() as there is a lot of info that suggests the use of /pmtimer in the C:/boot.ini file to fix incorrect timing results. I'm also unsure as to how well using SetThreadAffinityMask() works for timing, as I don't believe it provides any guarantees, only a suggestion. In another application that I was developing, using SetThreadAffinityMask() before calling QPC still gave me some timing results that were off, on 32-bit Windows XP (64-bit Windows XP, however, didn't have any such issues).
|
|
|
|
|
I want to export some functions from an executeable file. How to do it.....
In exe export function like below, and add .def file add foo to exports.
<br />
__declspec(dllexport) int __stdcall foo(int i, int j)<br />
{<br />
return i+j;<br />
}<br />
In another exe file invoke function like this:
<br />
typedef int (__stdcall *FOO)(int, int);<br />
<br />
HMODULE hModule = LoadLibrary("C:\\Export.exe");<br />
if (hModule != NULL)<br />
{<br />
FOO pFun = (FOO)GetProcAddress(hModule, "foo");<br />
if (pFun != NULL)<br />
{<br />
TRACE("%d\n", pFun(1, 3));<br />
}<br />
}<br />
I Got an "Access Violation" error.
Hongjun Ge
|
|
|
|
|