|
Call GetClipboardData(CF_BITMAP) or GetClipboardData(CF_DIB). You may want to call IsClipboardFormatAvailable(...) first it see if there is a bitmap available.
HANDLE MyGetClipboardBitmap()
{
HANDLE hClipBitmap = GetClipboardData(CF_BITMAP);
if( hClipBitmap )
{
HANDLE hCopy = MyMakeCopy(hClipBitmap);
return hCopy;
}
return NULL;
}
The above example did not call the OpenClipboard() or CloseClipboard(), which you need to call before trying to get anything from the clipboard.
The "Clipboard Functions" page in the MSDN library is kind of hard to locate, but it is there.
Good Luck!
INTP
|
|
|
|
|
when i try to set the wallpaper using this function i can only set a bitmap, to the best of my knowledge its suposed to work for all formats. anyone have any idea as to why it wont set anything but bitmaps?
note: OS = Win M.E.
if not if you know how to infom the desktop that the registry key has been changed then that would work just as well
|
|
|
|
|
As far as I know, it can only do bmp
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
I have been trying to figure out how to use a try/catch throw statement to handle a file input error. All the block has to do is check to see if the file exists...if the file does not exist then it displays the message "File xxx.xxx does not exist." Any help is greatly appreciated. I have been trying to read my programming book on try/catch throw but it doesn't really give you a good idea how to use it with ifstream.
David Slone
|
|
|
|
|
By default the IOStreams libraries set error bits, if you're looking to use iostreams with exceptions you'll need to specify this manually. The following sample was based on http://www.cplusplus.com/ref/iostream/ios/exceptions.html
int main () {
ifstream file;
file.exceptions ( ifstream::eofbit | ifstream::failbit | ifstream::badbit );
try {
file.open ("test.txt");
}
catch (ifstream::failure e) {
cout << "Exception opening/reading file";
}
file.close();
return 0;
}
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts your aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
hi everyone..
i want to use mktyplib to make a tlb from an odl file but i get this error:
fatal error M0006 : unable to pre-process input file
i tried the mktyplib that comes with VStudio .net and the one that comes from VStudio 6 but both give the same error...
i thought the file might be wrong in syntax or something like that but i tried alot of odl files especially the ones that come in the include directory..
|
|
|
|
|
I am a MDI project. it gets data from outside and display them. I think the data should in Doc class. so I and Data object in MyDoc. I create a thread to read peripheral at 50ms interval. and call MyDoc::HandleData(). everything is fine so far. but when execute to there pDoc->UpdateAllViews(NULL) inside HandleDate(). It ASSERT(FASLE), (debug mode). I know it is because thread problem.( there are explain in the void CWnd::AssertValid() const. I wonder if there is a easy solution. anybody have idea?
|
|
|
|
|
It has been a while!
Essenualy your thread should not be calling function in you document class. I would sugest you thread safe class (directions in MSDN library) which you allocate and initialize in your document (a ponter to data). Pass a pionter to the data class to your thread and use event signals to inform you when the data has changed. This may require you to use OnTimer() some where to check when an modified event has occured.
MyClass::OnTime()
{
if( Event happened )
UpdateAllViews(NULL);
}
MyClass::OnUpdate( CView* pSender, LPARAM lHint, CObject* pHint )
{
if( pSender != this )
InvalidateWindow();
}
MyClass::OnPaint(...)
{
pDoc->mydata.lock();
pDoc->mydata.unlock();
}
Oh well, it should work something like that. You would probably want to maintain to copies of the data one for used by the your updata thread and one that holds a copy of the last update, that way you will not be trying to lock data access every time you need to repaint the data (leads to some unexpected results).
As usual there are some articles at CP on the subject and who knows one of them may have already solve your problem.
I hope this helps a little!
Oh! One last possibility is to use a CMemFile(), they can be share by multiple thread via a handle. By you'll still need a method to determine when the data has changed.
Good Luck!
INTP
|
|
|
|
|
OnTimer() won't work for Doc. What is "thread safe class"?
|
|
|
|
|
Type "thread safe class" in the index section of the MSDN library window, the information should be baried in there some where.
The OnTimer() function is the tricky part, for the method I was thinking about. You would only need to receive timer messages in one of your views, which would probably call one of your document function to make a copy of the udated data (before posting the update-all function). The problem is that if you close that view you would stop receiving the timer messages.
If the application only displays views of this particular data (and nothing else), then you could use an OnTimer() function in your main window and update the first document (of the specified type) you find from there.
Of cource with this last method you could store the data globaly and ignore the actual document class all together. (just using multi-doc to simplify the creation of multiple views)
Using a multi-doc interface in this fashion seems like a bit of a cludge, but it can work.
There is also the possiblity of creating a hidden view of the data that receives the OnTimer() messages (That is created just when the first visable view is created). You would have to close this view after the last visable view was closed.
Keep in mind that you may not even need to gather the data in a seperate thread, because unless you are recording each change for future use or study you only need it to update the views and (depending on the amount of data, and number of views) it may take longer than 50ms to do that.
Well if nothing else I hope I have stimulated your imagination with other possiblities.
Taa! Taa!
INTP
|
|
|
|
|
You can't (easilly) use any CWnd functions from a thread that the CWnd wasn't created in. The best way to handle your problem is to use PostMessage() to post back to the main thread and get it to update the views.
Alternatively you could set a flag in your document whenever the data changes and then use CDocument::OnIdle() to check the flag and call UpdateAllViews() if it set, and then reset the flag.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Thank you for your suggestion. It sounds great. But I already figure out a solution. I'd like to share with friends.
in stead of set a flag, I postmessage( CMainWnd* , WM_COMMAND, ID_XXX, 0 ). this Command is post to Mainframe, mainframe then routed to CDoc. so In MyDoc, just handle OnCmdMsg(ID_XXX, handler).
enjoy it.
Thanks to all your kindness reply
|
|
|
|
|
My project shows 3 help files in the Solution Explorer:-
Help Files
-- My_Prog.cnt
-- bullet.bmp
-- afxrtf.rtf
Currently when help is selected (say F1 key) I get the blank default page.
e.g.
<<YourApp>> Help Index<br />
<br />
<< Write a topic here that discusses your application's main dialog.>>
Now if I right click on the My_Prog.cnt file and open it with hcrtf I can added Help items into it but when I test it (Contents OK) I get the error:-
The topic does not exist. Contact your application vendor for an updated Help file. (129). But my program does not call up the correct file, still get the default help page.
Now I started to use a freeware program Cheetah to added the rtf data and also used Microsoft WorkShop (hcrtf)to take the Cheetah produced rtf file and compile to help files.
I can produce a help file that works fine on its own.
But how do I integrate it into my project.
If I copy over the new help files into the project I get the following error when I try and run Help.
The topic does not exist. Contact your application vendor for an updated Help file. (129).
I did try renaming files, and adding/removing help files from the project etc, but still no luck.
I seem to be going around in circles, any Help out there?
Can I link in the compiled Help producted by the freeware program and Microsoft Workshop.
Or how can I write the help using Visual Studio?
grahamfff
|
|
|
|
|
i want to know how to delete a character in a text file. if i use '\b' or ascii 127(del), then i get some special characters in my file instead the characters getting deleted. Probably windows doesnt recoznise these characters as dos does. Is there any other way or any other character that can be used to delete charactes in a file either backwards or forwards ??? I use visual studio.net as my compiler.
Pls hlp.
Nikhil
|
|
|
|
|
1) Open (for read/write) the file read it into a CString or std:string, find the character you want to delete and then use the appropriate function call to delete it from the string, finaly move to the beginning of the file and write the string back to the file.
2) You could also just allocate a buffer larg enought to hold the entire file (+1, buffer must end w/NULL), read the data into the buffer, find the character, then use memmove function to delete it, finaly writing back to the file.
3) You could also read it into a large buffer then write it back to the file while skip the character that you want deleted.
4) (worst way of all - this is realy bad)
Open a tempory file and the origanal, read 1 character at a time from the origanal file and write it to the tempory file, when you find the character you want to delete then just do not copy it to the temporay file. Once you reach the end of the file you could copy the tempory file back to the origanal (or delete the origanal and rename the temporary with the origanal name).
Use your imagination, there are more ways to skin this cat than I count. But one way that you cann't do it is by inserting anouther character into the data stream.
Good Luck!
INTP
|
|
|
|
|
Hi,
I need to find out the free disk space ona computer on LAN , given the computer name. I need this to determine wether i can create a new database on a remote computer running SQL Server.
I am really in a fix over this.
Any help will be deeply appreciated.
Thanks in advance.
|
|
|
|
|
Hey. I can draw properly in the OnPaint function, but when I move my code over into the OnTimer function to work with dynamic data the code isn't drawing anything.. Any of you know what is the proper way to draw dynamic content in a Dialog Box ?
thanks.
|
|
|
|
|
You should do all your drawing int the OnPaint function. The OnTimer function should do as little as possible. For example you could set some flags when OnTimer is called and then invalidate the area (or whole dialog) that needs to be redrawn and let the OnPaint do its job.
In other words the OnTimer function should not be trying to draw any thing. If you draw anything outside of the OnPaint function it will be drawn over the next time OnPaint is called.
Good Luck!
INTP
|
|
|
|
|
Okay, Right now, whenever I need to redraw with new data, I call Invalidate Rect(). It's working okay except for the flickering but there's a lot of articles on codeproject that help with that, just haven't had time to read through them. Working on the network protocol right now.
Thanks
|
|
|
|
|
The flickering problem is easy to solve: just override the OnEraseBkgnd() so that it does not draw the backgound, then draw the background youself. If you are drawing every object yourself, then you could draw them first and use ExcludeClipRect() to remove them from the invalide rectangle follow by a call to Rectangle() to fill the background.
With the drawing method mentioned above you'll probably never see any flickering at all. I have used this method in multiple projects (See code from CExBitmap article at CP).
I know you probaly did not need this info yet, but I thought it help speed things along.
Good Luck!
INTP
|
|
|
|
|
I have an application where I have the listview control. I have implemented a sort, ascending and descending, which seems to work. The question I have is that I would like to implement the "sort arrow" on the column that is sorted. By "sort arrow", I am referring to the triangle that you see on the sorted column in Windows Explorer. I would like to show the "sort arrow" up (standard rightside up triangle) if sorted ascending and vice versa if sorted descending. Any ideas or code snippets that I can use?
|
|
|
|
|
Hello,
I have problems with reading a text file with 'cyrillic' or other texts encodings and producing XML from it.The text file itself should be ANSI and I read and convert the bytes using MultiByteToWideChar() to the codepage 1251 for cyrillic then I get those bytes and put it in the XML. On my computer it would work and the output XML is displayed correctly but on other people computers it won't work even though they have the codepage 1251 installed !!!! They get '?' symbols for the text when viewing with IE .
I have tried saving the XML UTF-8 and UTF-16 both failed to display it correctly.
I am using MSVC6.0 and compile with _UNICODE only but still it won't work.
Someone please give me a hint how to fix this.So, far anyone I ask is helpless...
|
|
|
|
|
|
I have an old dll developed in house a long time ago. It was part of an earlier project and was signed by verisign (the certificate has long since expired).
I'm using this in a project now but the expired signature is causing problems with initializing the application. Is there any way to cleanly remove the expired signature from the dll ? I have no information on the purchase of the certificate so renewing it or cancelling it now will be a problem.
"One of the Georges," said Psmith, "I forget which, once said that a
certain number of hours' sleep a day--I cannot recall for the moment how
many--made a man something, which for the time being has slipped my
memory."
|
|
|
|
|
I would like to paint a focus rect around the inside of my buttons, I can not figure out how to make a brush that is the text color every other pixel (like the standard windows buttons focus rect)
wWw.KruncherInc.cOm
|
|
|
|