|
Dan_K wrote: I don't know why my CPU usage shoots up to 100%
Time to start learning how computers work.
It's time for a new signature.
|
|
|
|
|
I have a strange problem : an .pdf file load in IE is not printed !
I made an MDI project , with CView based on CHtmlView , where I load an .pdf file. The problem is that Print , from File menu not working !!! If I load an any other kind of file ( .html , etc. ), Print function ... Why ? I work in VC6 , and I have Foxit pdf client ...
|
|
|
|
|
Ok , I found the problem , it was my pdf client : Foxit Reader .
|
|
|
|
|
Hi,
I am working in a porting project where i have to convert the thread local variables (declared with __declspec(thread)) to TLS allocations (using TLS APIs).
I am able to do it for variables.
How to do it for function pointers? (thread local function pointers)
for example,
I have a thread local function pointer declared as,
__declspec(thread) BOOL (WINAPI *Test)(Short a, _TCHAR b, BOOL c);
Is it possible to convert this by using TLS APIs?
Is it possible to allocate the memory (4 bytes) for pointer "Test"?
Any help is appreciated.
Thanks.
Selva
|
|
|
|
|
Test is just a variable with type:
BOOL (WINAPI *)(Short, _TCHAR, BOOL );
so all you need to do is cast the result of you TLS allocation to that type. If you use a quick typedef it's pretty trivial:
typedef BOOL (WINAPI *test_function_ptr)( Short, _TCHAR, BOOL );
test_function_ptr Test = (test_function_ptr)malloc( sizeof( test_function_ptr ) );
Replace malloc with what ever TLS function you're using and snip, snip, Bob's your Aunty.
Cheers,
Ash
|
|
|
|
|
Hi Ash,
Thanks. It works.
Selva
|
|
|
|
|
Hi all,
i want to use Codeproject Left Sidebar type sidebar in my SDI type Splitter MFC application.
please tell me how can i use it .
if possible please tell me any other styles and designs of side navigation bar.
thanks in advance.
|
|
|
|
|
You would probably need a Tree View[^] control, or CTreeView[^] class.
It's time for a new signature.
|
|
|
|
|
Can u please show me any example or demo application its really help me.
|
|
|
|
|
You really should learn how to use MSDN/Google/Bing for yourself. Try here[^] for some explanations and samples.
It's time for a new signature.
|
|
|
|
|
how to check the window is opened or not in a win32 application
|
|
|
|
|
FindWindow and FindWindowEx are what you want. You have to know the window class or the title of the window you're digging for but not both.
Cheers,
Ash
|
|
|
|
|
If "opened" stands for "visible" than IsWindowVisible is the API.
If "opened" means "existent" than IsWindow is the API.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
VS2008 puts a manifest file in my exe automatically (the "embedding manifest" build step). But when I start the exe it shows the dialogs in the classic theme. I opened the exe in the resource editor and noticed that the manifest lacked "Common Controls" section. How can I fix that?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
WTF?! Why does the New Project Wizard add the #ifdef _UNICODE...#endif
#ifdef _UNICODE
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_IA64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif
in the code that adds the XP style buttons.
This code was created by the wizard, no changes from me. It basically means "I'll create a manifest for you unless your program is ANSI, in which case f**k you". When I removed the #ifdef everything worked without problems. The only purpose for putting it seems to be to make me waste an hour wondering why I don't have visual styles, and creating 2 projects one with manifest one without, and comparing them with WinMerge, before noticing this little insidious #ifdef. And I'm sure there are people who don't know about the whole manifest thing, they'd be stuck with ugly controls if they make an ANSI project. I've made my project ANSI from the beginning since I had to add a lot of code that won't compile if it's unicode.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
sashoalm wrote: WTF?! Why does the New Project Wizard add the #ifdef _UNICODE...#endif
Because technically... common controls 6 and above does not have full ANSI support. Some window messages will be returning Unicode text buffers if you use common controls 6 in an ANSI build. Depending on your application architecture... you may or may not bump into this limitation.
Best Wishes,
-David Delaune
|
|
|
|
|
Hi Everybody,
How to find a text file is already opened or not?
I have used the following code. but it is not working correctly.
ifstream inFile;
inFile.open("C:\\test.txt");
if (!inFile)
{
AfxMessageBox("file is opened");
}
else
{
AfxMessageBox("file not opened");
}
can anyone help me to how to find a file opened or not?
Thanks....
G.Paulraj
|
|
|
|
|
It all depends on how you opened the file. There's no reason why you can't have two streams based on the same file. e.g. on my system:
int main()
{
std::ifstream str1( "c:\\test.txt" );
std::ifstream str2( "c:\\test.txt" );
int n = 0;
int m = 0;
if( ( str1 >> n ) && ( str2 >> m ) )
{
std::cout << "Woo hoo! Opened both!" << std::endl;
}
}
Always comes up with the "Woo hoo!" message and both n and m are set to the integer that's in the first token of the file.
Unfortunately there's no way of opening a file using the standard library that locks it against further reading so if you're using streams you're not going to be able to tell easily if someone else has got it open.
Cheers,
Ash
|
|
|
|
|
Paulraj G wrote: I have used the following code. but it is not working correctly.
What do you mean by not working? Your example shows an open of a single file with no sharing restriction. Please explain what you are trying to do and what results you receive.
It's time for a new signature.
|
|
|
|
|
Paulraj G wrote: How to find a text file is already opened or not?
Try opening the file in exclusive mode... filebuf::sh_none
If you are unable to open the file exclusively then it means another application has an open handle.
Best Wishes,
-David Delaune
|
|
|
|
|
Quick caveat here: filebuf::sh_none is not standard C++. You might end up with problems if you need to compile your code on another compiler.
Cheers,
Ash
|
|
|
|
|
Paulraj G wrote: How to find a text file is already opened or not?
It quite difficult, try to open file in write and sharedenyall , if it fails that means somebody else already open the file otherwise none.
Preconditon: file must exists at stated path
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
You can use CreateFile Function[] with "OPEN_EXISTING" flag in 5th argument(__in DWORD dwCreationDisposition) and use GetLastError Function to determine f the file opened already or not. Read complete documentation for the above.
--
"Programming is an art that fights back!"
|
|
|
|
|
Hello All,
I have a code snippet as follows
struct ItemNode
{
CString szID;
};
void DoSomething()
{
ItemNode *a = NULL;
TRY {
CString s;
s.Format (_T("%s"), a->szID);
}
CATCH(CException b){
MessageBox (_T("Exception occured"));
b->Delete ();
}
END_CATCH
return;
}
Here, I am not able to catch the exception. The app crashes saying "There is an access violation.... "
What is the correct way to catch the exception??
I am using C++, MFC and the development is in VisualStudio 2005.
|
|
|
|
|
Try like this for instance:
void DoSomething()
{
ItemNode *a = NULL;
TRY {
CString s;
s.Format (_T("%s"), a->szID);
}
CATCH(...){
MessageBox (_T("Exception occured"));
}
END_CATCH
}
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|