hi ppl, I got this framework which obiously includes windows.h... :mad: And I got a static library which includes afxwin.h. I need afxwin.h because I want to use CCmdTarget class. And I got this error: WINDOWS.H already included. MFC apps must not #include <windows.h> :mad: I am not creating a MFC application and I need CCmdTarget class and I cannot remove windows.h... :~ Any workarounds?? :confused: Thank you all.. :)
dehseth
Posts
-
WINDOWS.H already included. MFC apps must not #include <windows.h></windows.h> -
How to use message queue in CCmdTarget Derived class?Hey guys, How can I enable my class, which is derived from CCmdTarget, to use message maps and message queues.
-
Function PointerOK I forgot to mention the most important thing :-\ I want to point my function at run time. I mean it should be any kind of function pointer which accept this. So this is not acceptable for me &A::run... I do not need boost for that (this will do the job if I already knew the class):
class SomeClass;
typedef void (SomeClass::* SomeClassFunction)(void);
void Invoke(SomeClass *pClass, SomeClassFunction funcptr) {
(pClass->*funcptr)(); };Seems like there's no way... :(
-
Function PointerHey everybody, Let's see if I have this code:
class R
{
public:
typedef void (*Method)();
Method onClick;void Do() { (\*onClick) (); }
};
void ok()
{
printf("OK\r\n");
}int _tmain(int argc, _TCHAR* argv[])
{
printf("main\n");R r; r.onClick = &ok; r.Do();
...
Just runs. :thumbsup: Function pointer works.. But if I try to point a NON-STATIC function of a class.. well cant do that! :doh: I need to pass class instance also.. :) But dunno if there's a way to do that without templates. :| So any idea how to do that without using template? :) To make it clear:
class A
{
public:
void run(void);
};class R
{
public:
typedef void (*Method)();
Method onClick;void Do() { (\*onClick) (); }
};
void ok()
{
printf("OK\r\n");
}int _tmain(int argc, _TCHAR* argv[])
{
printf("main\n");A a; R r; r.onClick = &a.run; //wont work r.Do();
...
-
Pointer.NET won't satisfy my needs. Garbage collector slows me down. :)
-
PointerNope, but thanx... :)
-
PointerJust need it... :)
-
PointerHey ppl, I have two pointers and one value:
int* p1 = new int;
*p1 = 10;int *p2;
p2 = p1;Now p1 and p2 has different addresses (of course). They both points the same unnamed integer value. Lets delete p1:
delete p1;
p1 = NULL;Now p1 is NULL and referenced the only integer is deleted. Now if I try
delete p2;
p2 = NULL;Just crashes cause int which is referenced by p2 is not valid anymore. So how can I check if int is still valid OR maybe make p2 = NULL when object is deleted.. I read about shared pointers with templated which are not good for me to use right now? Any workarounds?
-
Static Library IssueI just delete all Temp files Debug Output files and Release output files. Rebuild library. And rebuil application. Now it runs.. :thumbsup: Sometimes we need housekeeping i guess.. ;)
-
Static Library IssueApplication compiles and link successfully: ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ========== But when I double click to generated exe file it crashed X| So I open visual studio window and press Run button and it gives me these errors :wtf: I do not get why I get em. There's no c1xx file... :confused: Should I do anything more than putting #pragma comment (lib, "mylib") and include the main header file to make it run on release mode? :confused:
-
Static Library IssueHey ppl, I have create a static library project and build it successfully on debug mode and release mode. :thumbsup: Now I have a different project which uses this static library with #paragma comment (lib, mylib) When I compile and run my project in debug mode it runs successfully. :) When I compile my project in release mode it compiles successfully but wont run. :doh: And when I try to run release mode inside Visual Studio it gives me these errors: Error 1 fatal error C1083: Cannot open source file: '.\XWindow.cpp': No such file or directory c1xx Error 2 fatal error C1083: Cannot open source file: '.\XTexture.cpp': No such file or directory c1xx Error 3 fatal error C1083: Cannot open source file: '.\XTextBox.cpp': No such file or directory c1xx Error 4 fatal error C1083: Cannot open source file: '.\XText.cpp': No such file or directory c1xx Error 5 fatal error C1083: Cannot open source file: '.\XPen.cpp': No such file or directory c1xx :wtf: ... list goes on. These files are included in mylib.lib that's why I used static lib. So why this happens? :confused: One more thing, my library's file size in debug mode is 3.103Kb and in release mode 11.349Kb. I expect it would be more less in relase mode.. :~ Thank you... :-D
-
Tell linker to add cpp filesYeah that's what I did.. Thank you. ;) I create a static library put all my .h and .cpp files in it and compile create my .lib file. And put it into my application. Now it works.. :thumbsup: Thank you again. :-D
-
Tell linker to add cpp filesActually this is exacly I am trying to avoid... I do not want to add .cpp files. But if I have to then I will.. So any other suggestions?
-
Tell linker to add cpp filesError 1 error LNK2019: unresolved external symbol "public: __thiscall CXControl::~CXControl(void)" (??1CXControl@@QAE@XZ) referenced in function "public: __thiscall CXDesktop::~CXDesktop(void)" (??1CXDesktop@@QAE@XZ) DX.obj This is one of the errors... SO how can I tell Linker/Compiler to do that :confused:
-
Tell linker to add cpp filesHey guys, I got a linker problem.. I have written some .h files and .cpp files for being used in any project, and put them to a folder named "common". :) Now I have a project and I set up the vc directories. I add include and source file folders to there. And I include the main .h header file. Compiling is ok :) but when it comes to linking linker says unresolved external symbol :doh: ... So it couldn't find the body in the cpp file. So how can I tell the linker to use the cpp file? :confused: Thank you... :-D
-
Pure Functions..wow you are totaly right... :thumbsup: i did change their names and it worked... :-D i do not use MFC in my app but still I add windows.h, windowsx.h.. :^) anyways... thank you very much.. :)
-
Pure Functions..Hey ppl, I got stuck with this pure thing.. I got a class which contains pure functions: virtual void OnMouseDown(int Button, int X, int Y) = NULL; virtual void OnMouseMove(int X, int Y) = NULL; virtual void OnMouseUp(int Button, int X, int Y) = NULL; virtual bool OnRender(void) = NULL; And I have a derived class which overrides these methods: bool OnRender(void); void OnMouseDown(int Button, int X, int Y); void OnMouseMove(int X, int Y); void OnMouseUp(int Button, int X, int Y); But the compiler says: Error 5 error C2535: 'void CXWindow::OnMouseDown(int,int,int)' : member function already defined or declared Error 6 error C2535: 'void CXWindow::OnMouseMove(int,int)' : member function already defined or declared Error 7 error C2535: 'void CXWindow::OnMouseUp(int,int,int)' : member function already defined or declared Error 12 error C2535: 'void CXWindow::OnMouseDown(int,int,int)' : member function already defined or declared :doh: Ok! if I remove my override functions compiler says: Error 22 error C2259: 'CXWindow' : cannot instantiate abstract class d:\my codes\chess\chess\dx.cpp 16 :( Since I do not override them it says this is abstract! :wtf: Ok one more thing that i've noticed: OnRender method is also defined pure abstract but I do not get any error about that! Only difference is it does not contain any parameter and returns bool... :confused: thank you in advance...
-
CAtlRegEx Unhandled ExceptionHey there, I have a string which includes Turkish chars. And a regex pattern.. my mfc app is compiled with MBSC (I am pretty sure) I got an error at the last letter says unhandled exception.. my string is (i am not sure if you can see it properly) "paylaş" so last letter makes rgx throws an error.. I kinda deep search about the error I would like to write it if needed.. So what am I missing why it fails on turkish chars? I do not define any type of CharTraits I mean I create my variable in this way: CAtlRgx<> myregx; did not specify char type between "<" and ">" thank you all..
-
bool?means: int m; if (Addr) { m = 1; } else { m = 5; } check Addr (? -> check) if its true use first expression (1) else use second one (5)
-
Long Running Programtry "sleep(0)" this will make windows execute its message queue here's msdn explanation: A value of zero causes the thread to relinquish the remainder of its time slice to any other thread of equal priority that is ready to run. If there are no other threads of equal priority ready to run, the function returns immediately, and the thread continues execution. A value of INFINITE indicates that the suspension should not time out.