|
apoorva_raje wrote: ...written in a disk using fopen(), fgetc(), fputc()...
Do you enjoy reading & writing one byte at a time?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
I have tried to use the Win32 clipboard API to copy text to the clipboard, but ist doesn't show up when I try to paste it to a text editor. There is also no Clipboard Format available in the clipboard when I use EnumClipboardFormats. I've used a tutorial cooking book to write that code.
Can you say what's wrong?
Thanks.
void Clipboard::setTo(string const strData)
{
string::size_type const sizeData = strData.size() * sizeof(TCHAR);
HANDLE hData = ::GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, sizeData);
if (hData) {
LPTSTR tszData = static_cast<LPTSTR>( ::GlobalLock(hData) );
memcpy(tszData, strData.c_str(), sizeData);
::GlobalUnlock(hData);
::OpenClipboard(NULL);
::EmptyClipboard();
::SetClipboardData(CF_TEXT, hData);
}
UINT uiFmt = 0;
do {
uiFmt = ::EnumClipboardFormats(uiFmt);
} while (0 != uiFmt);
::CloseClipboard();
}
Werner
|
|
|
|
|
void CopyToClipBoard(char * buf,DWORD MAXSIZE)
{
HANDLE handle;
char * str;
if(OpenClipboard(NULL))
{
EmptyClipboard();
handle = GlobalAlloc(GMEM_MOVEABLE,MAXSIZE+1);
if(handle)
{
str = (LPTSTR)GlobalLock(handle);
memcpy(str,buf,MAXSIZE);
GlobalUnlock(handle);
SetClipboardData(CF_TEXT, handle);
}
CloseClipboard();
}
}
Does this work?
I don't believe in failure. It is not failure if you enjoyed the process.
|
|
|
|
|
Have you used the debugger to check return values, and the value of variables such as size_type , hData , and tszData ? What does SetClipboardData() return?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi everyone,
If I run SetThreadPriority and set a value for nPriority it return Nonzero but I cant see any change.
why it doesnt work?
Thanks
|
|
|
|
|
messages wrote: ...I cant see any change
Where do you expect to see a change?
|
|
|
|
|
Thanks Mark for your reply
I want to know if I change priority what happen if I change normal to low or...?
|
|
|
|
|
|
Hi
I have a need to generate reports, in PDF, in my VC++ application. I've seen numerous libraries that will take the pain away and make my life easier but I'd like to create my own library that will allow me to generate these reports.
If anyone could point me in the direction of some examples or tutorials I would be grateful.
Thanks
|
|
|
|
|
I think the easiest way is to preapre your reports for printing in the traditional way and send them to a PDF application. There are a number of free applications available. I tkink it must be possible to change the interfacing to the printer classes so that they look like a create PDF button or whatever you like.
|
|
|
|
|
|
He specifically said that he wanted to do that by himself. Did you take a look at the link you provided ?
|
|
|
|
|
humm i think that link is quite good. This tutorial can help baerten. As i think he is afraid of those libraries. So this link helps.
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
Adobe has, on their site, a developer section containing links to the PDF standard documentation.
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
Thanks, I visited Adobe and the reference material is quite good, however it lacks real world examples, e.g. if you'd like to create a table or insert an image things start to go wrong very quickly.
Also I created a pdf by printing a word document through a driver I found and if you open the file in textpad you cant see any of the text, as if its been hidden away or encoded in some way.
There seems to be a variety of Libraries out there and Text3PDF on code project is very good but I'd really like to create my own library, so I dont have to worry about license fees, having my own license updated or pay royalities.
This really seems to be a tricky area... Thanks for all the help tho, as it really helpful.
|
|
|
|
|
_Tom_ wrote: Also I created a pdf by printing a word document through a driver I found and if you open the file in textpad you cant see any of the text, as if its been hidden away or encoded in some way.
I think that when you create a PDF by using a "PDF printer driver", it treats the whole document as a bitmap / raster image. If you use Acrobat Reader to open a PDF document which was created by a PDF printer driver, you can't select text.
|
|
|
|
|
Hi,
i made this structure of my project
FRAME -> THREAD -> VIEW ( -> = creates )
In the Taskmanager i see that a new Thread is created if i open the Frame ( MDI-Child )
In Spy++ it's the same, 3 Threads for all the application, in the "ViewThread" i see the components
So far so good
But if i execute a nice loop on a Button-Click
int u=0;
for(int i=0; i<100000000000; i++)
u=0;
the entire application is freezed.
But this code is located in the CFormView object which is a part of the Thread ...
Why does all the application freeze?
Many thanks
PS: The Thread is a derived class from CWinThread
In the InitInstance() function i create the CFormView object
|
|
|
|
|
Remember when I said "When messages are sent between threads, it will block the sending thread and cause a context switch to the receiver, which nullifies the point of making the app multi-threaded"? Guess what's happening in your app...
|
|
|
|
|
Is the best way to let the Frames & Views in the standard thread
and create only for the "hard working functions" a Worker-Thread ?
Thanks
|
|
|
|
|
baerten wrote: Is the best way to let the Frames & Views in the standard thread
and create only for the "hard working functions" a Worker-Thread ?
To put it short: Yes!
The most common reason to use worker threads is to keep the GUI responsive during operations that will take a lot of time. The task is handed over to a thread that usually posts(!) a message to the main thread when it's done. The main thread is the one that also handles the GUI.
The use of worker threads for solving other kind of problems should be carefully considered in order to prevent design flaws and performance bottlenecks.
The most common mistake related to multithreading is the use of ::SendMessage() between threads. As Mike said "it will block the sending thread and cause a context switch to the receiver, which nullifies the point of making the app multi-threaded". This will cause a deadlock, it's just a matter of time.
The remedy for this is to use ::PostMessage() instead.
This is also the reason that the GUI shall never be manipulated from a secondary thread using MFC since those calls will result in a call to ::SendMessage().
Keep in mind that multithreading is not the same as real multitasking.
My point is that if you post a message to a thread, the message will not be handled until the receiving thread is given a time slice to run in by the OS.
This means that you have to expect a latency before action is taken on the request that is represented by the posted message. Nowdays you can assume this time to be about 10ms under normal circumstances. For Win95 it was about 55ms.
Regarding your initial post there might be other design flaws or bugs that are not related to the use of multiple threads. Aqueel's post points out one. Even if your variable could hold a value that big, you can expect your application to freeze and the GUI to be non-responsive since your burning a lot of MIPS in a UI-handler for a button click event.
Hope this helps
--
Roger
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"No one remembers a coward!" - Jan Elfström 1998 "...but everyone remembers an idiot!" - my lawyer 2005 when heard of Jan's saying above
|
|
|
|
|
I am afraid, i can not accommodate 100000000000.
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
Before you get to deep into threads, and unable to surface, read here and here.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
How to check in registry whether a software is installed?
Please give me some examples using VC++(MFC).
Many Thanks,
Vijay
|
|
|
|
|
|
Many thanx brahmma,
Now i am able to check from registry & it's working fine.
Rgds/Vijay
|
|
|
|