|
Hi i want to get HFONT or LOGFONT form HDC object. I have a hdc but i don't wann to do this in this way
<br />
HFONT font= (HFONT)SendMessage( hwnd,WM_GETFONT,0,0);<br />
or in this way
<br />
HFONT font = ::CreateFontIndirect(....);<br />
HFONT hOldFont = (HFONT)::SelectObject(hdc, font);<br />
im looking for something like
<br />
HFONT font=GetFont(hdc);<br />
There must be a way to do this
Pain is a weakness living the body
|
|
|
|
|
Try ::GetCurrentObject(HDC, OBJ_FONT)
Roger Allen - Sonork 100.10016
Strong Sad:
Clever I am? Next to no one.
Undiscovered and soggy.
Look up. Look down. They're around.
Probably laughing. Still, bright, watery.
Listed among the top. Ten.
Nine. Late night. Early morn.
Early mourn. Now I sleep.
|
|
|
|
|
Thanks!!!!!
Pain is a weakness living the body
|
|
|
|
|
Assuming that you don't want to create a font because it's expensive, what about
HFONT tmp = (HFONT)SelectObject(hdc,GetStockObject(DEFAULT_GUI_FONT));
SelectObject(hdc,tmp);
You don't say why you don't want to use the other methods...
Steve S
|
|
|
|
|
roger's way is what i was looking for
thanks anyway
Pain is a weakness living the body
|
|
|
|
|
Hello,
I want a function which will format some text with carriage returns in it. So that I have a maximum width like 80 characters. If my string is perhaps 180 characters I would like to look through the string and every 80 characters replace the nearest space character to the left of my maximum width with a carriage return. Is there a function that anyone has that can do this?
Thank you
|
|
|
|
|
the screen driver does this automatically.
anyway, you could do the simple (according that your string is str, C-style string):
<font style="color:blue;">int</font> iCpt = 0;
<font style="color:blue;">while</font> (str[iCpt] != <font style="color:purple;">'\0'</font>) {
<font style="color:blue;">if</font> (!(iCpt%80)) {
printf(<font style="color:purple;">"\n"</font>);
}
printf(<font style="color:purple;">"%c"</font>, str[iCpt]);
iCpt++;
}
or the more complex code below (i'm not even sure it works) :
<font style="color:blue;">int</font> iCpt = 0, iResult = 80;
<font style="color:blue;">while</font> (iResult == 80) {
iResult = printf(<font style="color:purple;">"%80s\n"</font>, str[iCpt]);
iCpt += iResult;
}
TOXCCT >>> GEII power
|
|
|
|
|
I do not want to break up any whole words.
I can show you. If my maximum width is 8 characters and this is my text:
aaa bbbb ccccc ddddd eeeeeee fff gg hhhhh
I want to have this:
aaa bbbb\nccccc\nddddd\neeeeeee\nfff gg\nhhhhh
So my result would be this:
aaa bbbb
ccccc
ddddd
eeeeeee
fff gg
hhhhh
|
|
|
|
|
ahh ok, well if you don't say it, how should i guess...
hem, i'm thinking of this :
* add a marker to record the last whitespace you encountered before the end of the line,
* create a buffer 81 caracters long (because of the trailing '\0') where you copy the caracters (and so WORDS) to printf,
* when you encountered the end of a line, or the end of the source string, copy the buffer to the screen
TOXCCT >>> GEII power
|
|
|
|
|
suppose your string is
char str[]="......"
<br />
#define MIN(a, b) (((a) < (b)) ? (a) : (b)) <br />
<br />
int str_len = strlen(str);<br />
int LINE_LEN=7;
int c=(int)ceil((float)str_len/(float)LINE_LEN);<br />
char *str2= new char[str_len+c+1];<br />
int n=0;<br />
int m=0;<br />
for(int k=0;k<c;k++)<br />
{<br />
m= MIN(LINE_LEN,str_len-LINE_LEN*k);<br />
strncpy(str2+n,str+(LINE_LEN*k), m );<br />
n+=m;<br />
str2[n++]='\r';<br />
}<br />
str2[n]=0;<br />
delete[] str2;<br />
<br />
Pain is a weakness living the body
|
|
|
|
|
Hi everybody,
Does anybody know, how I can use a WTL splitter window in an MFC 6.0 project? I want to have a more flexible splitter window in my MFC application. please explain it in detail.
thanks in advance,
Roozbeh.
|
|
|
|
|
wot is the best way to check whether internet is connected.
Other than pinging or downloading file from a known server.
|
|
|
|
|
take a try...
InternetCheckConnection(...)
jitendra
|
|
|
|
|
A function for this is InternetAttemptConnect . This function will check if an Internet connection is available. It returns ERROR_SUCCESS if the connection was available, and if not, it'll return one of the system wide error codes.
Only one parameter, zero, is issued to the function, so it's pretty straightforward to call it. Include 'Wininet.h' and link with 'wininet.lib' to use this function. It is part of the Platform SDK.
For other Internet-connectivity functions, see MSDN link here.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
InternetGetConnectedState(...)
|
|
|
|
|
Hi,
how to I restart my program from its own. Now I do it with a batch file,
it looks like this:
1) process starts a batch-file
2) process stops
3) batchfile waits 2 seconds
4) batchfile starts the process again
Has anybody a better solution ?
Thank you,
Mario
|
|
|
|
|
ShellExecute(NULL,"open",MyAppPath,"-r","",SW_SHOW );
PostMessage(hWnd,WM_QUIT,NULL,NULL);
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
suhredayan® wrote:
ShellExecute(NULL,"open",MyAppPath,"-r","",SW_SHOW );
whats -r ???
God is Real, unless declared Integer.
|
|
|
|
|
Mr.Prakash wrote:
whats -r ???
Hi Prakash,
Missed to explain the paramaters. Can omit "-r", which can be otherwise used to indicate the application was restarted.
Please check my signature.
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
PostQuitMessage(NULL) would be the better choice then
PostMessage(hWnd,WM_QUIT,NULL,NULL);
jitendra
|
|
|
|
|
Jitendra gangwar wrote:
PostQuitMessage(NULL) would be the better choice then
PostMessage(hWnd,WM_QUIT,NULL,NULL);
If PostQuitMessage(NULL) is called from within a userinterface thread which is one of the many, within your application.
It just posts a WM_QUIT message to the thread’s message queue and returns immediately; the function simply indicates to the system that the thread is requesting to quit at some time in the future.
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
suhredayan® wrote:
If PostQuitMessage(NULL) is called from within a userinterface thread which is one of the many, within your application.
It just posts a WM_QUIT message to the thread’s message queue and returns immediately; the function simply indicates to the system that the thread is requesting to quit at some time in the future.
If PostQuitMessage(NULL) is called from within a userinterface thread which is one of the many, within your application.
It just posts a WM_QUIT message to the thread’s message queue and returns immediately; the function simply indicates to the system that the thread is requesting to quit at some time in the future.
But according to MSDN --
Remarks
The WM_QUIT message is not associated with a window and therefore will never be received through a window's window procedure. It is retrieved only by the GetMessage or PeekMessage functions.
Do not post the WM_QUIT message using the PostMessage function; use PostQuitMessage.
|
|
|
|
|
PostQuitMessage(0);
form within another UI Thread will not exit the application.
But PostMessage(hWnd,WM_QUIT,0,0);
will be caught by the underlying handlers and the application will get exited for sure, provided its the handle to the main window.
so i feel suhredyan's method atleast ensures that the application is exited.
|
|
|
|
|
I am agree with you.
Thanks for correcting me.
|
|
|
|
|