|
Turn your bits into a DIBSection, then just draw that to the screen in WM_PAINT, taking into account the positions of the scroll bars.
also take the scroll positions into account when a user clicks.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I'm basically trying to output *.ppm and *.pgm files. The file format of ppm is a simple header followed by 24 bits for RGB for each pixel. For the pgm it's a simple header followed by 8 bits per pixel.
I can read and display the ppm files using this bit of code:
<br />
BITMAPINFO bi ;<br />
bi.bmiHeader.biSize = sizeof( BITMAPINFOHEADER );<br />
bi.bmiHeader.biWidth = m_nWidth;<br />
bi.bmiHeader.biHeight = -m_nHeight;
bi.bmiHeader.biPlanes = 1;<br />
bi.bmiHeader.biBitCount = 24;<br />
bi.bmiHeader.biCompression = BI_RGB;<br />
bi.bmiHeader.biSizeImage = ::abs( m_nWidth*m_nHeight ) * 3;<br />
bi.bmiHeader.biXPelsPerMeter = 100;<br />
bi.bmiHeader.biYPelsPerMeter = 100;<br />
bi.bmiHeader.biClrUsed = 0;<br />
bi.bmiHeader.biClrImportant = 0;<br />
<br />
::SetDIBitsToDevice(<br />
dc.GetSafeHdc(),<br />
0, <br />
0,<br />
m_nWidth, <br />
m_nHeight,<br />
0, <br />
0,<br />
0, <br />
m_nHeight,<br />
m_pImage, <br />
&bi, <br />
DIB_RGB_COLORS );<br />
However this doesn't work for the pgm images. I don't know what header to set or how to display it unless I physically take the data I loaded in the pointer and insert R=G=B=original grayscale data.
|
|
|
|
|
Hi Guys
I want to prevent my app getting terminated by the taskmanager. I saw some examples but they are using dlls that you have to pay for. So I informed myself a bit about that. I figured out that i've to use SetWindowHookEx. And there we are at my first problem: What type of Hook should i use ? i prefered WH_CALLWNDPROC. And how do i have to realize the main loop ? Is it a function that i get with the hook ? I'm never used hooks before, but i'm sure with some help i could do it.
MFG
RedDragon
P.S.: The code will never be used to cause any damage to hard- or software. I'm working on a program which controls pupil pc's.
Unix and C are the ultimate computer viruses.
|
|
|
|
|
|
Yeah i see. I read this articles, too. But it is POSSIBLE. A programmer already done so. You can find the demo app on: http://www.madexcept.com/ under c++ and then go to MadCodeHook. Yeah you can come with this argument: Why don't you even this code ? Well, how could i get better when i just copy or use dlls from others ?
MFG
RedDragon
P.S: Excuse my bad english
Unix and C are the ultimate computer viruses.
Visit me: www.programming.info.ms
|
|
|
|
|
If your application is has a window, use classview and add the windows message handler: OnQueryEndSession. In the body, return false, and your application will prevent any shutdown that does not use the EWX_FORCE switch.
Himanshu
|
|
|
|
|
RedDragon2k wrote:
I'm working on a program which controls pupil pc's.
Have the students using accounts that do not have permission to terminate your process (which can be run under a different account).
Just about anything else is dodgy as hell, and will eventually be broken by any student worth his salt.
"The time has come," the Walrus said,
"To talk of many things..."
|
|
|
|
|
Hai All,
In my application InitInstance method the DoModal() calling of main application dialog return -1(bcoz of some loading problem). but i want to capture it and show some error mesage. But i cann't show any error message or any other dialog when it returns -1.
How i can i solve this problem.
ANyone can have any idea?
regards
Ans
|
|
|
|
|
|
AnsGe wrote:
But i cann't show any error message or any other dialog when it returns -1.
The reason is most likely here.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hai,
I tried with ur help. But my problem still remains.
If main window is successfully loaded then it is possible to show any mesagebox. But the main window Domodal() failed then it is not possible to show a MessageBox. The code snip running, but windows are not visible
Thanks
Anish
|
|
|
|
|
AnsGe wrote:
...then it is not possible to show a MessageBox.
Did you comment out the m_pMainWnd = &dlg statement in the app's InitInstance() method?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Whenever I've had DoModal() return -1 it was due to the dialog using a control whose window class wasn't registered yet. If you're running an older OS and are using any Win 95 common controls, check that you're calling InitCommonControls() in your init code.
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ | You Are Dumb
|
|
|
|
|
hai,
Thanks for ur reply.
i know the exact reason why it retuns -1. bcoz one my ocx is not installed in the machine. But i want to capture the situation and want to display error message.
I have done all hte initialisations in the InitInstance
Thanks
Ans
|
|
|
|
|
Hai All,
How can i check an ocx which is droped in my main application dialog is installed or not. I not used the CoCreateInstane function , but i directly placed the control in my dialog. The application crashes when the control is not installed.
How can i avoid it?
Thanks in Advance
Ans
|
|
|
|
|
You can try the CoCreateInstance before attempting to display the dialog. If that fails, do not show the dialog.
|
|
|
|
|
Hai,
Actually i don't know the internal structure about the used COM component. Its a 3rd party control and i have only know some functions in it. I dont know any classid and interface id's.
So how can i call CoCreateInstance()
Byy
Anish
|
|
|
|
|
Just trying to help here, but maybe you can use this:
HRESULT CLSIDFromProgID(
LPCOLESTR lpszProgID,
LPCLSID pclsid
);
You have to already know what the name of the OCX object is to use the function.
Otherwise, you might need to manually search the registry to find where the OCX is installed, find the OCX, see what it's GUID is, and then try to use the CoCreateInstance.
|
|
|
|
|
hi ans,
cocreateinstance is not required to instantiate the activex. i think your problem is u r not included the call to AfxEnableControlContainer(). it ll intializes the framework needed for the activeX container
naren
|
|
|
|
|
I have a gui application that is launched via createprocess(...) from another gui application (that subsequently kills itself). This new application creates a secondary thread that creates a dialog (hidden) at thread creation. I am looking for windows shutdown requests on this secondary dialog (using onQueryEndSession()), and then attempt to show this dialog. It works correctly for most cases (e.g. when I press ctrl+alt+delete and then select shutdown), but sometimes I get a "System Settings Change" Message Box which appears after new devices installed. In this scenario, my application catches and prevents the shutdown request, but fails to throw up the dialog when I use ShowWindow(SW_SHOWNORMAL) (by the way, its modeless). Does anyone know why a messagebox like this would cause this behaviour? I found that uninstalling a device brings up a similar messagebox (same caption, different text), but in this test my modeless dialog does appear. Any suggestions would be appreciated.
Thanks,
Himanshu
|
|
|
|
|
I am using the AlphaBlend function with an image on a transparent window to fade the image in with a timer and an alpha value incrementing from 1 to 255 as the timer fires (I'm redrawing using InvalidateRect), how can I fade the window back out? If I use the same redraw function and decrement the alpha value the images stays the same.
Am I going about it the right way? Is there a way to fade out?
|
|
|
|
|
|
Thanks for the reply, I tried AnimateWindow() before but I keep getting the error that it is an undeclared identifier even when I include windows.h as specified in the MSDN Library. What am I doing wrong?
|
|
|
|
|
|
Cheers, I've cracked it now, just had to define the windows version.
|
|
|
|