|
It is because you never destroy your pointer (_instance). There is a new but no delete associated. You need to add a 'destroy' public method to your singleton that will delete the pointer. And you need to call this function at the end of your program (or when you want to delete your singleton).
Another way of doing that (and you won't need to manage the memory yourself) is to use this init method instead (still static method):
Singleton* Singleton::Init()<br />
{<br />
static Singleton Instance;<br />
return &Instance;<br />
}
Of course, you can remove your static pointer.
BTW: when you post code, please use the code or pre tags so that it is more readable.
|
|
|
|
|
Cedric,
Thank you for your explanation.
Andrew
|
|
|
|
|
Hi,
I have created a new window with following method
AfxGetMainWnd()->SendMessage(WM_COMMAND, ID_FILE_NEW);
But when I print some data on this window the the data is printed on the
view window alongwith the scroll bar.What should be the problem?
When I press the left mouse button on the area where the scroll bar is
supposed to be then the scroll bar appears until then the scroll bar is
invisible.
Thanks
Pritha
|
|
|
|
|
I think the problem is in the code which creates that new window, or the way you are printing over it. It seem the new window does not know that a scroll bar is there
|
|
|
|
|
Hi,
thanks for your reply
Yes It seems so.
But do I make the window aware that a scroll bar is in this place. Is there any way to do that?
Since I have created the window only with this one method
AfxGetMainWnd()->SendMessage(WM_COMMAND, ID_FILE_NEW);
through which I get a new window.
I then get the window pointer and print data on the window with the help of this window pointer.
I have not done anything more than this.
Please Guide
Prithaa
|
|
|
|
|
Do You use MDI
if then what kind of view you are using
|
|
|
|
|
Hi,
Yes I use MDI my view is derived from CSrollView
Thanks
Prithaa
|
|
|
|
|
the problem might be with the way you print in the view.
you should check it
|
|
|
|
|
Hi,
I don't think that the problem lies in not printing correctly since the routine with which I print on the screen works fine when I get a new window through File/New command in a Doc-View architecture.Here I pass the 'this' pointer to my routine and print on the window which I got through the File-New command in the menu.
But now when I pass a window pointer of a child window which I just created through
AfxGetMainWnd()->SendMessage(WM_COMMAND, ID_FILE_NEW);
then I get error of printing on the scroll window.
There must be some problem with window initialization which the File-New command must be doing .
Prithaa
|
|
|
|
|
Also try PostMessage instead of SendMessage.
Mark
|
|
|
|
|
Hi,
No it did not help
Please guide me with something else instead.
Prithaa
|
|
|
|
|
prithaa wrote: I pass the 'this' pointer to my routine and print on the window which I got through the File-New command in the menu
Sounds like maybe you are drawing on the frame window? You need to draw on the view window.
Try GetActiveView() to get the window to draw on.
Mark
|
|
|
|
|
Hi Mark,
Thanks for the help
It worked,I tried GetAvtiveView()and it worked.
Bye
|
|
|
|
|
i dont know but i think in the hook i have detours 1.5 and in microsoft visual basic include folder there might be detours 2.1 arent they conflicting themselfes ?
detours library yes i have look at the includes :
[code]/
in main.cpp i have :
#include <windows.h>
#include <stdio.h>
#include "main.h"
#include "opengl.h"
#include "detours.h"
#pragma warning(disable:4100)
#pragma comment(lib,"detours.lib")
void WINAPI glDrawElements_Detour(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
void WINAPI glDrawElements_Trampoline(GLenum, GLsizei, GLenum, const GLvoid *indices);
bool WINAPI DllMain(HMODULE hDll, DWORD dwReason, PVOID pvReserved)
{
if(dwReason == DLL_PROCESS_ATTACH)
{
DetourFunctionWithTrampoline((PBYTE)glDrawElements_Trampoline,(PBYTE)glDrawElements_Detour);
hTtnDll = hDll;
DisableThreadLibraryCalls(hDll);
sycoreReDirectFunction("kernel32.dll", "GetProcAddress", (DWORD)&pGetProcAddress);
return TRUE;
}
return FALSE;
}
////////////// in opengel.cpp i have
#include <windows.h>
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#include <gl gl.h="">
#include <gl glu.h="">
#include <gl glaux.h="">
#include <math.h>
#include "CRC.h"
#include "ASM_GL_CALLS.h"
#include "opengl.h"
#include "main.h"
//#pragma warning(disable: 4244)
#include "detours.h"
#pragma warning(disable:4100)
#pragma comment(lib,"detours.lib")
DETOUR_TRAMPOLINE(void WINAPI glDrawElements_Trampoline(GLenum, GLsizei, GLenum, const GLvoid *indices), glDrawElements);
void WINAPI glDrawElements_Detour(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
{
if (MODELS_1)
{
show_****_modelz();
}
if (MODELS_2)
{
show_****_modelz();
}
if (MODELS_3)
{
show_****_modelz();
}
if (MODELS_4)
{
show_****_modelz();
}
glDrawElements_Trampoline(mode, count, type, indices);
}
and in opengel.h i have this void APIENTRY omfg_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
/[code]
and i get this error and i dont know what do to :::
Linking...
main.obj : error LNK2001: unresolved external symbol "void __stdcall omfg_glDrawElements(unsigned int,int,unsigned int,void const *)" (?omfg_glDrawElements@@YGXIHIPBX@Z)
Release/BASE_GL_HOOK.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
BASE_GL_HOOK.dll - 2 error(s), 0 warning(s)
i think this is right using ?
typedef void (*void WINAPI glDrawElements_Detour) ();
typedef void (*void WINAPI glDrawElements_Detour) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
or is this :
typedef void (WINAPI *glDrawElements_t) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
glDrawElements_t glDrawElements_Detour;
|
|
|
|
|
You give a header for your function omfg_glDrawElements but there is no body. You need to provide a body for this function.
Did you post all your code ? Because it is weird... And, btw, use the pre or code tags when you post code.
|
|
|
|
|
ok but void APIENTRY omfg_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
how to do a a body for it that not gives me errors ? and this function is hooked i think or should i write in opengl.h void WINAPI glDrawElements_Detour(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); insted off omfg_......
-- modified at 4:13 Tuesday 24th October, 2006
this is hooked in opengel.h i dont know how to detour it it needs to be hooked and also detoured how do i do this thats the point !
|
|
|
|
|
Is that a function that is defined by yourself ? Or is it part of a library ?
If it is written by yourself, and you if you call this function, the nyou will get this linker error if there is no body defined with the function (you just provided a prototype, so now you actually need to writte the function itself, which is called the body).
But I don't really understand what you did because your code is totally unclear. Could you post the code that is related to this function ? And use the correct tags so that it is more readable.
|
|
|
|
|
yes the function is defined bymyself and it is not part of a library and i cant post the whole source code coz im not in home il get friday night or saturday to home then well see about that greeetz for helping me and if u wanna please add me my msn is ivor99@hotmail.com then we could talk .
|
|
|
|
|
I was wondering how do I get text out of a textbox and use that as the filename? I'm making a program that keeps track of people and want to have their username as the file name, so each user has his/her own file.
|
|
|
|
|
try EM_GETLINE or WM_GETTEXT
|
|
|
|
|
stream = freopen( this->textBox1->Text, "w", stderr );
thats the line I tried, where would I put that?
|
|
|
|
|
im making a program that will list all the files in several dir. they all list except the Temporary Internet Files dir. and i know as of now there is 951 files any one know why it wont and how to make it list them to?
|
|
|
|
|
use
SHGetSpecialFolderPath()
clsid of "Temporary Internet Files" is
CSIDL_INTERNET_CACHE
after getting the path
you can use
FindFirstFile ()
FindNextFile()
I will help
|
|
|
|
|
use
SHGetSpecialFolderPath()
clsid of "Temporary Internet Files" is
CSIDL_INTERNET_CACHE
after getting the path <--- i made it that far but the rest is a weeeeee bit over my headand there is a catch its not just 1 dir. there is 3 of them on my pc
C:\\Documents and Settings\\jack\\Local Settings\\Temporary Internet Files
C:\\Documents and Settings\\Administrator\\Local Settings\\Temporary Internet Files
C:\\Documents and Settings\\Default User\\Local Settings\\Temporary Internet Files
i want to scan all 3 but i can only get the path to the first one.
|
|
|
|
|
Hi,
You can use API from Wininet:
FindFirstUrlCacheEntry
FindNextUrlCacheEntry
FindCloseUrlCache
-----------
Mila
|
|
|
|