|
Ok,
yes I am using mfc.
Can you recommend any good articles on importing its type library in the application?
Once i import it, can i then code pretty much the same as as explained in the tutorial i followed in my original post? ie. will i be able to use myWordDoc.SaveAs" for example? Or will it be completely different because im not using the com object?
Thanks very much for you help.
|
|
|
|
|
tmoney101 wrote: Can you recommend any good articles on importing its type library in the application?
I've not read article , you mentioned.
But you can see this article and ofcourse this article.
It shows how it can be used
|
|
|
|
|
Hi ,
I need to read the active font in the present forground window, which i trying
to do with the below sample code. But every time i execute the "GetTextFace" i get the
Font Name as "System ". I kept the foreground window as the "note pad" and if this
program is executed i always get the Font name as "system".
{
HFONT m_font;
int buf_size = 10000;
char* m_gbuf = new char [buf_size];
MAT2 m_mat2;
unsigned char chr= 'L';
int total_size ;
int divider =0;
RECT MsgRect;
memset(&m_mat2, 0, sizeof(m_mat2));
m_mat2.eM11.value = 1;
m_mat2.eM22.value = 1;
TEXTMETRIC *lptm = new TEXTMETRIC;
LOGFONT *lplf = new LOGFONT;
hwnd = GetForegroundWindow();
m_dc = GetDC(hwnd);
GetTextFace(m_dc, buf_size, m_gbuf);
printf(" %s \n ",m_gbuf);
GetTextMetrics( m_dc, lptm);
lplf->lfCharSet = ANSI_CHARSET;
strncpy(lplf->lfFaceName, m_gbuf, sizeof(m_gbuf));
lplf->lfHeight = lptm->tmHeight;
lplf->lfItalic = lptm->tmItalic;
lplf->lfUnderline = lptm->tmUnderlined;
lplf->lfStrikeOut = lptm->tmStruckOut;
lplf->lfPitchAndFamily = lptm->tmPitchAndFamily;
lplf->lfWeight = lptm->tmWeight;
lplf->lfWidth = lptm->tmAveCharWidth;
lplf->lfClipPrecision =0;
lplf->lfEscapement = 0;
lplf->lfOrientation = 0;
lplf->lfQuality = 0;
lplf->lfOutPrecision = 0;
m_font = CreateFontIndirect(lplf);
if(m_font == NULL)
printf("failed ");
SelectObject(m_dc, m_font);
GLYPHMETRICS gm;
chr= '1';
total_size = GetGlyphOutline(m_dc, chr, GGO_GRAY2_BITMAP, &gm, buf_size, (void*)m_gbuf, &m_mat2);
}
Can anyone please help, to capture the Font that is active in a Specified Window if we know the handle of that window.
I dont know much abt fonts and i am sure that i am terribly missing something, please help.
Thanks in Advance..
|
|
|
|
|
If you know the handle to the window why not just send the WM_GETFONT message? Another thing you can do is get the windows DC and use the GetCurrentObject() function. These will return a handle HFONT with which you can use the GetObject() function to fill in a LOGFONT structure.
It's possible that you have got the wrong window handle. Maybe you have the main HWND of the app which usually has the System font, but most text operations are within child controls which have their own window handles. Just like Notepad, the window font is system, but the Edit control is user defined.
|
|
|
|
|
waldermort is correct.
GetForegroundWindow() returns the main window , thats why it happend.
Try Enumerating child window (using EnumChildWindow , and you can check the class object is EDIT like that.)
Regards
krishnan
If u can Dream... U can do it
|
|
|
|
|
Thank you very much
i coudl get the font settings for the notepad window.
can you point me to documentation where i coudl find the
Edit like class for each diffrent windows ( like Windows word, word pad etc)
Once again, i thank both of you.
|
|
|
|
|
I'm a very beginner in C++ , and I use serveral days wrote a JumpTigger for WLS. JumpTigger just like a webspider. It helps you find friends' Spaces through your root space(and iterate), and finally gives you an output as a treelist(see this http://artex.xh.googlepages.com/output.html[^]). I must admit the Tigger isn't efficient, although I used multithread in my program .Tigger now used about 5 minutes and find(I prefer to say "jump") about 1200 spaces. Too slow?
Ok, if you are interested in Tigger, and want to help me(or teach me) to optimize my poor code. Please visit:http://artex.xh.googlepages.com/JumpTigger.rar[^] for Binary files.
And http://artex.xh.googlepages.com/JumpTiggerCode.rar[^] for source code.
Thanx, my friend;P!
//T I double Ga eR. That spells Tigger!
|
|
|
|
|
Artex_xh wrote: I'm a very beginner in C++
Artex_xh wrote: although I used multithread in my program
<ironical> This I find awesome. Took me quite some time as a beginner in C++ to come to multithreading, not the thing I tackled right away. Congrats. </ironical>
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
Hello everyone!
Hey, I think I've seen some Telnet server that allows you to download files... Is this possible? What are the commands? Thanks!
Windows Calculator told me I will die at 28.
|
|
|
|
|
The Telnet protocol itself is simply a very thin layer over a TCP connection. You can't download files over it directly, unless both your client and the server support it. I'm pretty sure the Windows telnet client doesn't.
The FTP protocol shares some features with Telnet.
For simple(-ish) text-based protocols, you can do some troubleshooting with a telnet client. Examples: SMTP, HTTP, POP3. Yes, you can send mail directly by telnetting to an SMTP server on port 25. However, you can't make any mistakes in typing, since backspace isn't interpreted - you can't edit a line.
|
|
|
|
|
Does anyone know how to determine the current count associated with a semaphore?
Let me explain. I have a server app that creates a background thread every time a client app makes a request. Before each background thread is created my app goes through ::WaitForSingleObject(m_hSemaphore, INFINITE) to ensure that I do not exceed a safe number of concurrent threads. When the background thread finishes its work, it calls ::ReleaseSemaphore(m_hSemaphore, 1, NULL) to balance the semaphore count.
There are times that I need to wait for all background threads to end (for example when the program ends). If I could check for the current semaphore count, I would know how many background threads are still running.
Currently I'm keeping a counter (protected with a critical section) that is incremented when the background thread starts and decremented when it ends. This works but it seems somewhat silly since this information is implicit in the semaphore object.
There is yet another possibility, The 3rd argument of ::ReleaseSemaphore() is a pointer to a LONG that receives the previous count. However, it seems to me that there is a problem here since you have several threads writing to this LONG at about the same time without any thread synchronization mechanism. Semanticaly, I need something like ::GetSemaphoreCount(m_hSemaphore). So far as I know such function does not exist.
Thanks,
Julberto Danray
|
|
|
|
|
|
That's a good idea but I want to emphasize that the motivation to determine the number of active threads via the semaphore handle is to simplify the code. The mechanism I'm currently using gets the job done. However, complexity is the enemy of good code. A solution based on a GetSemaphoreCount-like function would be not only simple and elegant but very understandable to anyone maintainig the code. For the time being it is likely that I will continue to use the method descrived in my original post.
Julberto
|
|
|
|
|
|
Thanks for the links to the article and books. I'll look into them.
By the way, it is important to me to know when all threads are done so the code can proceed to release resources. The background threads are somewhat short-lived since they just generate a synthetic HTML page and send it to the requesting client. The foreground thread waits until all background threads (if any) are done and then deletes the server object.
Julberto
|
|
|
|
|
I don't like polling, so I always use WaitForMultipleObjects()
I would have liked if they made it possible to have an event signaled every time the sempahore is in an unused state. You could simulate this by writing a small function with a critical section with the semaphore code inside and a counter.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
If you want to use GetSemaphoreCount(), try Linux
In windows, such function could be
long GetSemaphoreCount(HANDLE hSem)
{
long tmp=0;
if (WAIT_TIMEOUT!=WaitForSingleObject(hSem,0)) ReleaseSemaphore(hSem,1,tmp);
return tmp;
}
Good luck
|
|
|
|
|
#define *** 0x000000AE
For hours now I have been trying to find out why my code was not working. It's that above message!! I've been playing with the icon on the titlebar and for some reason everything I did was painted over, even though I trapped just about every message I could think of. Through the aid of spy++ I found the culprit!
|
|
|
|
|
I believe it is undocumented. In WinUser.h the closest value is :
#define WM_NCXBUTTONDBLCLK 0x00AD
|
|
|
|
|
That was the first place I looked. A search on google has only revieled a few symbian references, nothing which would have an effect on what I am doing. It is sent prior to a WM_NCCALCSIZE message, with 0x04 in the wParam. I trapped it and returned 0, my app worked. Until I restarted VS when all of a sudden trapping it had no effect.
It doesn't matter, I wrote a function to bypass the whole routine. I now an animated icon on the title bar, and a static icon on the taskbar, switchable of course )
|
|
|
|
|
waldermort wrote: I now an animated icon on the title bar, and a static icon on the taskbar, switchable of course )
Great you got it all sorted out Is this going to give an article ?
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
Rage wrote: Is this going to give an article ?
I doubt it, most of the code is hijacked and modified to suit my needs. I think writing an article about this will get me into trouble. All I wanted was to create a re-usable library which would enable me to show animated icons, and to minimize the window to the tray (animated not just hide).
This is the first time for me to subclass a window. In MFC probably very easy, but for plain old Win32 it takes a few lines of code.
|
|
|
|
|
How do I set the background color of an individual edit box? Say it is IDC_EDIT1 and I want a red background with normal black letters.
|
|
|
|
|
Create a brush and override WmCtlColor()..i think that's the one.
|
|
|
|
|
Oliver123 wrote: ...I want a red background with normal black letters.
Black letters on a red background are not very contrasting and thus may be hard to read.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|