|
Seems like #pragma once is recongnized by different compilers, some of them for the UNIX environment, but IMHO resorting to it is a bad idea, because it is not standard, and the #ifndef guard does the job in a very reasonable and widely known fashion.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
#pragma commands are by definition compiler-specific. If some *nix compilers support it too, great, but the world of *nix compiling is pretty hairy due to all the variants of OSes and compilers. Stick to the #ifndef method which is guaranteed to work everywhere.
--Mike--
"Everyone has figured out what 'service pack' really means, so they had to go and change the language. Perhaps this is what Bill was talking about in the 'security is top priority' letter."
-- Daniel Ferguson, 1/31/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
I have 2 questions the first is there a simple way to change the font size of a particlar control (eg. listbox).
The second is that I have a simple function (attached) which just reads a file and places it's textual contents into the clipboard. When I paste the info in notepad it is one continuous line with the crlf characters a little boxes though if i paste into other things (like in visual studio) it is fine. Is there some way I can preserve the carriage return/line feeds in the clipboard so that pasting into notepad and anything else will have the proper contents of the file?
EmptyClipboard();
GlobalBuff = GlobalAlloc(GMEM_MOVEABLE,size+1);
buffer = (char*)GlobalLock(GlobalBuff);
while(!feof(file)) {
fread(readbuffer,1,255,file);
if(ferror(file)) {
MessageBox(NULL,strerror(errno),"Error",MB_ICONERROR);
exit(1);
}
strcat(buffer,readbuffer);
memset(readbuffer,0,strlen(readbuffer));
}
GlobalUnlock(GlobalBuff);
if(SetClipboardData(CF_TEXT,GlobalBuff) == NULL)
return FALSE;
CloseClipboard();
If posting of this code is not appropriate please let me know and forgive my insolence.
Any help or suggestions are greatly appricated.
Thanks,
Sean Cody
|
|
|
|
|
As for the first question, use SetFont . Read Mike Dunn's C++ FAQ for common mistakes prople make when using this method.
With regard to your second problem, I guess what's happening is that notepad requires lines to be separated by CR-LF pairs ("\r\n" in C++ code) and you are feeding it with LF separated text. Try opening your file in binary mode ("b" flag in fopen ), that should fix the problem.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I should have specified I am only using C and the bare Win32 API (no MFC) so that method will not work for me.
Though the fopen suggestion worked great. Thanks!
Sean Cody
|
|
|
|
|
I should have specified I am only using C and the bare Win32 API (no MFC) so that method will not work for me.
There are direct equivalents in Win32: message WM_SETFONT , Win32 function CreateFont ... so you should have no problems translating the solution to raw C/Win32.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I'll look into that.
Thanks again.
Sean Cody
|
|
|
|
|
Hi
I have a very little problem, but still it is a problem so please if you know any solution write me back.
How do you write this 2^4 in C++? When I write it in the program the compiler, compiles it as 2+4=6 when it should be 2*2*2*2.
thanks!
|
|
|
|
|
2^4 = 0010 ^ 0100 = 0110 = 6 which would explain why you are getting 6 as a result.
I would suggest using the following function located in math.h
double pow( double x, double y );
Sean Cody
|
|
|
|
|
There isn't an exponential operator in C. However, you do have the pow function.
Sort of sucks...
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
^ is the XOR operator in C. As others have said there is no raise-to-power operator.
--Mike--
"Everyone has figured out what 'service pack' really means, so they had to go and change the language. Perhaps this is what Bill was talking about in the 'security is top priority' letter."
-- Daniel Ferguson, 1/31/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
I am drawing something on the OnPaint or OnDraw Method which some times go beyound the Client Area so Scroll Bar activated. After that user can do any thing.
Through any event I want to convert whole client screen in to BMP. Problem is that when I took the Client Window Handle it is not giving the Data which is beyond theClient Screen (i.e., currently not visible but visible through scrolling).
What I do to grab whole thing which I draw on the Client View.
I am looking for any Code . . . any idea . . . any . . .
Thanks in adnavce.
|
|
|
|
|
I would create a memory bitmap the required size, select it into a memory DC, and call OnDraw(&memory_DC). The memory bitmap will now contain the entire view, independant of the window size.
---
Sonork 100.11743 Chicken Little
It may be that your sole purpose in life is simply to serve as a warning to others.
|
|
|
|
|
The ATL declarations in stdafx.h:
// the following lines are required for ATL support
#include "atlbase.h"
extern CComModule _Module;
//#include "atlcom.h"
#include "atlapp.h"
#include "atlwin.h"
#include "atlctrls.h"
#include "shellapi.h"
#include "atlctrlx.h"
The usage of CHyperLink:
CHyperLink MyLink;
// Mesage handler for about box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
MyLink.SubclassWindow(GetDlgItem(hDlg,IDC_MYEMAIL));
return TRUE;
The errors:
C:\WINDOWS\Desktop\WP\WulframPoller.cpp(1173) : warning C4003: not enough actual parameters for macro 'SubclassWindow'
C:\WINDOWS\Desktop\WP\WulframPoller.cpp(1173) : error C2059: syntax error : '('
Any idea what I'm doing wrong?
|
|
|
|
|
I want to access some controls on a CFormview (Edit, listboxes, ...) from a DLL
So I pass a pointer to the control to the dll.
But each time when I access a pointer, I get an assert (IsWindows() fails). When debugging, the pointer seems to be valid.
What is wrong ?
Greetings,
Niko
|
|
|
|
|
Without seeing your code is hard to know, but seems to me that you're trying to use the controls before they are actually created. Having a CFormView variable is not enough, it is only after Create is called on that variable that the controls come to life.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Did you "import" the dll into your project?
Mazy
You can find a solution (even a foolish one) for all problems (even big ones)
|
|
|
|
|
What is the best way to use a clipping region that is centered within the client frame that I could use to display graphics and perform hit testing plus keep a caret within this region?
I'v been reading my sdk doc's on gdi+, just havn't figured it out yet. Any suggestions on reading material? I heard Feng Yuan's book was good.
|
|
|
|
|
Feng Yuans's book is very good, But I do not think that there is anything in his book about hittesting.
What you can do is call the SetCapture function which will capture the mouse for the target window that wants to capture and contain the mouse. Then you can handle the WM_NCHITTEST message for that window. This message is called every time a mouse message is generated such as a WM_MOUSEMOVE, WM_LBUTTONDOWN and even the NC versions of all of these messages. There are about 20 altogether.
Inside of your WM_NCHITTEST handler you can determine the current position of the cursor. Use this data to determine if the cursor is in the region that you want to use to contain the cursor. Use the PtInRegion function. If the cursor is outside of the region call the SetCursorPos function to clip the position of the cursor.
|
|
|
|
|
Does anybody know the code for C++ 6.0 to allow it to search for a certain character in a sentence.
Ex: My name is Mike
Search for character M:
If found it tell me how many you found
If didn't found it tell me cannot find.
Thanks
|
|
|
|
|
Try learning some C, C++ - mostly data structures and some algorithms like KMP and Boyer-Moore - and then use Visual C++...
"Needless redundancy is the hobgoblin of software engineering." - Peter Darnell
|
|
|
|
|
CString::Find does some of the work for you.
Cheers,
/Fredrik
Sonork ID: 100.11430:PhatBoy
|
|
|
|
|
?
Any ideas? Any code? I can use the arrow keys, but
how can I use the tab key to navigate through a
MsFlexGrid control?
Please, please, any response any one can give me will
be greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
I don't know about MsFlexGrid,but in CP there are nice grids,check them,maybe they are useful for this task.
Mazy
You can find a solution (even a foolish one) for all problems (even big ones)
|
|
|
|
|
under MDI, an icon IDR_MAINFRAME is created. how can i load it to the mainframe so that when execute the program, the icon i created can appear on the mainframe?
can this bedone too for childframe?
|
|
|
|