|
Why not
class CShape {
public:
virtual void Draw(CDC* pDC) const = 0;
virtual ~CShape();
};
class CLine : public CShape {
public:
CPoint ptStart;
CPoint ptFinish;
CLine(const CPoint& ps, const CPoint& pf) : ptStart(ps), ptFinish(pf) { }
void Draw(CDC *pDC) const {
pDC->MoveTo (ptStart);
pDC->LineTo (ptFinish);
}
};
Then you can start adding other shapes to your system.
--
Only in a world this sh*tty could you even try to say these were innocent people and keep a straight face.
|
|
|
|
|
I run my VC on a Simplify Chinese Windows 98 . The font which could be selected of the VC editor is limit, only 5 types can be selected. I know it is different from the English Version of Windows. So I want to know how to make more font selections. Do I need to modify the registery table? Thanks!
|
|
|
|
|
Hi,
I have written this to draw the edge.
DrawEdge(pDC->m_hDC, &rect, BDR_SUNKENINNER , BF_BOTTOMRIGHT | BF_ADJUST);
Now i want to cahnge the edge color ,How can i do that?
|
|
|
|
|
I have some messages that are dispalyed in my application (error messages, welcome messages).
I was wodering what is the best way to define those strings:
1. in a resource file, or
2. define my own const CString object in a common header file.
I would like to hear your pros and cons on both options.
Thanks!
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
If you ever think of doing something like localisation, resources are the way to go (probably even a resource DLL).
But if you are happy with one (or maybe very few, with different binaries) languages, you can probably stay with const strings in your application.
Both are Unicode-ready, but when you choose english as your applications language, you will probably not need this.
Just my 2 Euro-cents
"My opinions may have changed, but not the fact that I am right."
Found in the sig of Herbert Kaminski
|
|
|
|
|
i have searched all over the MSDN to find a Function to chand this attribute
is there and Class Member of CWnd that can change the BackGround (of ForeGround )Color or Text Color.
tnx
Fight with the Best
Die like the Rest
|
|
|
|
|
To draw on a Windows pane, you need a windows device context (DC), which with MFC comes wrapped up in a CDC class. If you look in MSDN for CDC, you will find all sorts of drawing stuff.
"My opinions may have changed, but not the fact that I am right."
Found in the sig of Herbert Kaminski
|
|
|
|
|
i want to know how i can Draw a bitmap on a Window.
when i make a window and draw a Bitmap on it the window is still at top and my bitmap goes under the window:
cw=new CWnd;
cw->Create(_T("STATIC"), "99",WS_VISIBLE |WS_THICKFRAME ,CRect(0, 0, 20,20), this, 0xffff);
.
.
.
pDC->BitBlt(point.x-10,point.y-10,bm.bmWidth,bm.bmHeight,dc,0,0,SRCAND);
whats wrong ?
if anybody has a suggestion for attach a BitMap to a Window plz tell me.
|
|
|
|
|
Well, for starters, you're SRCANDing the bitmap over the window, I think SRCCOPY might be what you want, but I cannot remember, to be honest. Second, where are you drawing this ? It should be in OnEraseBackground.
How do you know it goes under the Window, surely the Window would cover it if it did ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
This makes me me crazy!
Tell me the C functions that can help me to separete the extension of a string like myfile.jpg .
thus, I only want the .jpg to be left.
And again, just tell me what C functions that perhaps help me with this. I want to build the code myself because this is a pretty much simple thing. I don't want sample code
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Why do you want C, as opposed to C++ ? In C, I'd probably just step back a char at a time, so use strlen to find out how long the string is, and step backwards.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Christian Graus wrote:
Why do you want C, as opposed to C++ ?
What you actually is saying is: Use std::string instead!
right?
I never learn to use that!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Rickard Andersson wrote:
I never learn to use that!
So now's your chance.
But I seriously thought when you said C, you meant C. What else would I think ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Christian Graus wrote:
What else would I think ?
You would think C!
I will update my socket class library to usec std::string instead of char* to make it more objectoriented.
Mary christmas every one!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
_splitpath ?
Cheers,
Fredrik
"Felix qui potuit rerum cognoscere causas."
|
|
|
|
|
using namespace std;
string string strExtension;
string strFileName = "myfile.jpg";
size_t nLastDotIndex = strFileName.find_last_of('.');
if(npos == nLastDotIndex)
cout << "Error! No extension" << endl;
else
strExtension = strFileName.substr(nLastDotIndex + 1);
--
Only in a world this sh*tty could you even try to say these were innocent people and keep a straight face.
|
|
|
|
|
I agree, use _splitpath. You may not want it, but it will give you the drive, dir, filename, and ext. It is only one line of code...
|
|
|
|
|
hi guys, I want to be able to detect mouse click on the desktop(not just any particular application window) , how do I do that? any sample code/suggestion is appreciated
|
|
|
|
|
SetWindowsHookEx() with WH_MOUSE is probably what you want.
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
would you elaborate on it a little? sorry I'm a bit new to windows programming
thanks
|
|
|
|
|
Have a look in the MSDN.
You call SetWindowsHookEx() with a pointer to a function that you supply. Windows will then call this function every time something mouse-related happens, giving you the HWND that the event is for, where the mouse is on screen, etc.
Since there may be more than one program listening for these mouse events, you need to make sure that you pass the event on, by calling CallNextHookEx().
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
thanks for the pointer, now I still have some problem of getting it to work,
I have the following callback procedure that tries to show the mouse position
LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lparam){
MOUSEHOOKSTRUCT* mousehook=(MOUSEHOOKSTRUCT*)lparam;
POINT p=mousehook->pt;
char temp[20];
sprintf(temp,"mouse position is %d %d",p.x,p.y);
MessageBox(hWnd,temp,"",MB_OK);
return 0;
}
and I did SetWindowsHookEx(WH_MOUSE, 0,hInstance,0); but MouseProc was never been called for some reason, what did I do wrong, the following is my code in detail:
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrev, LPSTR lpCmdLine, int Cmd) {
MSG msg;
// Setup and register the window class;
WNDCLASS wClass;
wClass.style =CS_HREDRAW|CS_VREDRAW;
wClass.lpfnWndProc =WindowProcedure; // callback-function;
wClass.cbClsExtra =0;
wClass.cbWndExtra =0;
wClass.hInstance =hInstance;
wClass.hIcon =LoadIcon(hInstance,IDI_APPLICATION);
wClass.hCursor =LoadCursor(NULL,IDC_ARROW);
wClass.hbrBackground =(HBRUSH)(COLOR_WINDOW+3);
wClass.lpszMenuName =NULL;
wClass.lpszClassName =WINDOWNAME;
RegisterClass(&wClass);
// Create the window and store the handle;
hWnd = CreateWindow(WINDOWNAME, // class name;
WINDOWNAME, // window name;
WS_OVERLAPPEDWINDOW, // window style;
CW_USEDEFAULT, CW_USEDEFAULT, // starting position (x,y);
320, 240, // width and height;
NULL, // parent handle;
NULL, // menu handle;
hInstance, // instance handle;
NULL); // other parameters;
// Check if window creation failed; otherwise show and update;
if(hWnd==NULL) return FALSE;
else {
ShowWindow (hWnd, Cmd);
UpdateWindow(hWnd);
}
HOOKPROC hookproc;
//static HINSTANCE hinstDLL;
static HHOOK hhook;
SetWindowsHookEx(WH_MOUSE, 0,hInstance,0);
// Message loop;
while(GetMessage(&msg,NULL,0,0)) {
TranslateMessage(&msg);
DispatchMessage (&msg);
}
return msg.wParam;
}
|
|
|
|
|
I was actually playing with this stuff the other day and couldn't get it work like this either I had to pass in the current thread ID when setting the hook i.e. call GetCurrentThreadId(). So it should work OK as long as everything is in the one thread, which it is for me. If you really want a global hook or for this work for multiple threads, you're on your own!
BTW, I wouldn't call MessageBox() inside your hook procedure. This function is going to get called a *lot*, from deep inside Windows, and it's probably not going to like you trying to display a dialog box. Log it to a file instead,
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
thanks, that worked, but now I have a seg fault due to the HHOOK i m passing to SetWIndowsHookEx, the following is what I have, I simply create a new HHOOK, is this wrong?
what is the HHOOK for? I read the msdn doc on it but still kind of fuzzy, thanks.
static HHOOK hhook;
SetWindowsHookEx(WH_MOUSE, hookproc,hInstance,GetCurrentThreadId());
|
|
|
|
|
sorry a correct to my previous post, when I say HHOOK, I meant HOOKPROC
|
|
|
|
|