|
Hey,
Could any one please tell me any idea on how can i solve this problem. I made a list box in which files can be added and can also be zipped. However, all of this is done in a while loop so the dialog isn't receivng any messages, kind of freezing until the loop is done. I would like to be able to click Cancel but it's not working. I tried inserting this in the middle of the loop:
CWinApp* pApp = AfxGetApp();
MSG msg;
while ( PeekMessage ( &msg, NULL, 0, 0, PM_NOREMOVE ))
pApp->PumpMessage();
but it makes it a lot slower and while the files are being zipped this won't work.
I created a worker thread but the problem is that i need to call functions like:
next = m_files.GetNextItem(next-1 ,LVNI_SELECTED );
which are non static so the compiler will give me an error. It won't work either with GUI thread. Any suggesions on how to fix this?
Thanks alot.
Regards,
Eric
|
|
|
|
|
Pass the HWND of the list control to your worker thread. You can then use the straight APIs to access the list (sending messages is safe between threads in the same process), or make a local CListCtrl variable and attach it to the window handle, if you prefer using CListCtrl methods.
UINT ThreadProc(void* pv)
{
CListCtrl list;
list.Attach ( (HWND) pv );
list.Detach();
return retcode;
}
--Mike--
http://home.inreach.com/mdunn/
Trillian: What are you supposed to do with a manically depressed robot?
Marvin: You think you've got problems. What are you supposed to do if you are a manically depressed robot?
|
|
|
|
|
Hey Michael, thanks a lot for replying. I'll try that. Thanks again.
|
|
|
|
|
How can i read RGB (0...255) data from Bitmap for each pixel?
|
|
|
|
|
Do you mean Bitmap (GDI+) or CBitmap (MFC) or HBITMAP (Win32) ?
MFC has GetPixel/SetPixel. You can select a bitmap into a DC and then use those. If you meant something else, just say.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I posted this elsewhere with no response, hopefully here it will see more action.
Alright, first, a quick explaination of my problem.
I make a piece of software that the company i work for uses to control logons to a computer. It is a computer rental place, and upon timing out the login screen has to pop up to the top of ANYTHING that could be running and stay there.
I have it running in Windows 9X, and is quite secure. I hide it from Control Alt Del menu right off the bat, and on the login screen i press it to the front with a collection of APIs called many times a second.
But we are considering moving to windows XP. Its task manager can see (and end) my process at any time, regardless of any API i have seen so far. Task manager cant stay in front of the login screen, but when someone logs in (the login screen goes away) they can simply end the task for the software!
Not Good!
So, I've been reading up on how this all works, and I have a couple ideas on how to fix it but no idea how to approach any of them.
#1: Run the program under alternate credentials. This WORKS (access denied trying to end my task), but damit, have to enter the password every time (very bad, many computers). Anyone know how to start a task under alternate credentials and have it start automatically? this would solve the problem, and i think it would be best. Storing the password in a batch file in plain text is NOT an option. some of our users are fairly good with computers.
#2: Run a stub-service that that checks for status of my login program, and starts it again if it disapears. Since the users will be low-access and the service runs under ./SYSTEM, it can't be stoped. so if anyone kills the task they will be greeted with the login screen when it starts back up. This would also work, but i have no idea how services work.
#3: Find an API that lets me once again hide the task completely like 9x. I dont like this at all, but if its the only way it will have to do.
#4: Any other sugestions?
Can anyone reccommend anything that would help me on this problem? we can keep using 9x for a while, but it would be nice to have XP in order to start pimping it when it hits the streets. That means i have to start working on it now to have it on systems by the 25th of oct.
// Rock
|
|
|
|
|
Can you place your code inside a service? Service process is visible in the task manager, but user can't kill it. If service runs on 'Local System' account, there's no need to enter the password. And even if you choose to run under different account, the password is stored in the services database - there will be no login dialog.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Yes, thats one of the things I mentioned in my original post, the problem is that I must:
a: display a user interface. can a service do this? if so, how?
b: learn how to implement services if so.
I am looking for specific information, not really general help, unless there is something that i did not mention in my original post. thanks for your post though!
// Rock
|
|
|
|
|
It's possible for service to have user interface when it runs under LocalSystem account.
Read "Interacting with the User in a Service" in Platform SDK. In my MSDN it's under Windowing/Window Stations/Using window stations and desktops. Sample code displays a msgbox, but I think it would be easy to display a modal dialog box.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
cool, thanks
i'll take a look.
// Rock
|
|
|
|
|
a: display a user interface. can a service do this? if so, how?
In the options for a service there's a checkbox called "Allow service to interact with desktop", if this one is checked it's possible for a service to show GUI-stuff.
b: learn how to implement services if so.
I can recommend a book called "Programming Server-Side Applications for Microsoft Windows 2000" from MS Press.
There's also a service sample included in the MSDN Library.
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Need to explain the d-heap insertion's complexity in term of big-oh, any idea? I know it is
O(d log^d N), but how it is derived?
Thanks.
|
|
|
|
|
Hi all,
I am writting an MFC app using the Doc/View and MDI. I can't figure out how to maximize my child frame when it gets created such that the restore, minimize, and close buttons appear up on the menu bar. I can get the window to maximize, but the buttons do not appear. I'm sure it is probably something simple that I am missing, but I just can't figure it out. When I click the maximize button I get the buttons, but I can't figure out how to do it in code.
Thanks,
Mike
|
|
|
|
|
Add this line to your OnCreateClient method in your CChildFrame class"
MDIMaximize();
|
|
|
|
|
I may have something messed up elsewhere, because that is what I was doing to maximize it before. I tried it in several locations in the OnCreateClient (I already was using this method to set up a splitter window) and I still don't get the buttons or the contol menu in the frame's menu bar. Any other ideas?
Thanks,
Mike
|
|
|
|
|
Try this:
void CChildFrame::ActivateFrame(int nCmdShow)
{
nCmdShow = SW_SHOWMAXIMIZED;
CMDIChildWnd::ActivateFrame(nCmdShow);
}
ActivateFrame is a virtual function, you can use ClassWizard to quickly add declaration and default implementation.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Sirs,
do you eventually know why the computer must be restarted 3 times when installing Windows?
Thanks
Bunburry
Education is an admirable thing but it is well to remember from time to time that nothing that is worth knowing can be taught (O.Wilde)
|
|
|
|
|
What Windows?
2K: I remember twice, and NT the Same. But if you are Installing some drivers, is common that you reboot the PC several times.
Cheers!!!
Carlos Antollini.
|
|
|
|
|
Sometimes you run into problems with layered drivers (not the right tech term).
Take for example the PCI Bridge driver. The computer installs the OS, reboots. Detects the PCI Bridge and installs the driver, reboots. This time, it detects the devices that required the PCI bridge, reboot.
That is just an example, probably not 100% true.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
Hi,
do you eventually know why the computer must be restarted 3 times when installing Windows?
Bunburry
Education is an admirable thing but it is well to remember from time to time that nothing that is worth knowing can be taught (O.Wilde)
|
|
|
|
|
I've developped a snap-in without using the ATL/COM app wizard. I started my project on a simple DLL and I based myself on the samples on MSDN. And now, I need to add some dialog boxes to my snap-in and I dont know how to include MFC without bugging everything else.
Scoob
|
|
|
|
|
This is probably spelled out someplace obvious, but I sure cannot find it so forgive me if this is too trivial.
I have my own file searching tool that looks at the contents of various Office documents. My tool currently uses some simple Perl script and OLE to dump the files in text format and then processes those text files into an index for later use in an MFC program. And, having expended the effort to do that, I find that "Fast Find" does pretty much the same thing, except that it handles more types of files than my program and it creates the indices about 4 times faster!
So, what I would like to do is be able to get at the text stored in those index files. These are the ones called ffastun0.ffx, ffastun.ffo, ffastun.ffl, and ffastun.ffa.
Somebody must have a C++ class to do this. Or failing that, some example code that can access these files.
I looked at the IFilter stuff referenced in the VC++ help, but it is pretty worthless. At least to me. It seemed to be for creating the index, not using the one already made by FindFast.
Pointers much appreciated.
BTW, I am a COM newbie, so any explanations should use small words.
Thanks!
|
|
|
|
|
I'm writing a DLL that captures live video from a digital video camera. I have a buffer that contains the "image", and I need to copy this image to the clipboard as a DIB.
If I call "SetClipboardData(CF_BITMAP, hBmp)", I get the black rectangle. If I call "SetClipboardData(CF_DIB, hBmp)", I get an error that says the (bitmap?) handle is invalid.
Here's my code so far. When I paste the image into another app, all I get is a completely black rectangle. Can anyone help? Notice, there's no MFC here, and that's the way I'd like to keep it.
if (::OpenClipboard(NULL))
{
::EmptyClipboard();
RECT rc;
HBITMAP hBmp;
HDC hDC;
HDC cDC;
HWND hWnd = myParmsPtr->liveHwnd;
::GetWindowRect(hWnd, &rc);
long lStillWidth = rc.right - rc.left;
long lStillHeight = rc.bottom - rc.top;
hDC = ::GetDC(hWnd);
cDC = ::CreateCompatibleDC(hDC);
hBmp = ::CreateCompatibleBitmap(cDC,lStillWidth,lStillHeight);
HGDIOBJ oldBmp;
oldBmp = ::SelectObject(cDC, &hBmp);
PAINTSTRUCT ps;
::BeginPaint(hWnd, &ps);
int prevMode = ::SetStretchBltMode(cDC, COLORONCOLOR);
::StretchDIBits(cDC,
0, 0, lStillWidth, lStillHeight,
0, 0, lStillWidth, lStillHeight,
cb.pBuffer, (BITMAPINFO*)(&cb.bih),
DIB_RGB_COLORS, SRCCOPY);
::SetStretchBltMode(cDC, prevMode);
::EndPaint(hWnd, &ps);
if (!::SetClipboardData(CF_DIB, hBmp))
{
LPVOID lpMsgBuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(), 0, (LPTSTR)&lpMsgBuf, 0, NULL);
MessageBox(NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION);
LocalFree(lpMsgBuf);
MessageBeep(0);
}
::CloseClipboard();
::SelectObject(hDC, oldBmp);
::DeleteObject(hBmp);
::DeleteDC(cDC);
::DeleteDC(hDC);
}
|
|
|
|
|
You shouldn't delete hBmp. From SetClipboardData docs:
After SetClipboardData is called, the system owns the object identified by the hMem parameter
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I think I have larger problems than that. Removing the line that deletes the hBmp doesn't hve any affect on the previously stated results.
|
|
|
|
|