Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
T

Tnarol

@Tnarol
About
Posts
32
Topics
14
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Disable selection highlighting in a CTreeCtrl
    T Tnarol

    Hi, Please help me find a way to disable or change the color of the selection highlighting in a CTreeCtrl. It is the same selection highlighting that is expanded by enabling the "FullRowSelect" option of a CTreeCtrl. Thanks.

    C / C++ / MFC help

  • Class member visibility problem
    T Tnarol

    Hi, I have a class X that instanciates many other classes that have no major relationship with it (no derivation...). However I need these classes to be able to see some members of the X instance that created them. It is not possible to use static members because they need to be specific to one instance of X. Do you see any possibility smarter than passing a reference on class X to every instanciated class ? Thanks.

    C / C++ / MFC help question

  • WindowProc and window class registration issue
    T Tnarol

    Exactly ! Thanks

    C / C++ / MFC question design help

  • WindowProc and window class registration issue
    T Tnarol

    Thanks, This solves my problem. I might be using a "std::map" instead to find the class instance knowing the hwnd but the idea is the same. I mostly wanted to check that it's not a bad design have the same WindowProc for all my instances and therefore have to lookup the class instance everytime.

    C / C++ / MFC question design help

  • WindowProc and window class registration issue
    T Tnarol

    Hi, I'm having a DLL that exports a class. Each instance of this class should be able to create its own window. Therefore I created a WindowProc class member to process messages to the created window. While trying to register a window class for my class I tried to configure the message processing by filling the lpfnWndProc field of WNDCLASSEX structure with a pointer to WindowProc. I couldn't get this to compile if the WindowProc function is not *static*. This is not acceptable because this means all instances of my class share the same WindowProc so I don't know which instance should process the messages. What is the appropriate design to do what I want ? Thanks

    C / C++ / MFC question design help

  • EnterCriticalSection() exception issue
    T Tnarol

    Thanks, it works fine so far...but the exception occurs very rarely so time will tell. The problem with this kind of class is that you have to leave critical section explicitly so if you have functions with many return points you must copy the "Leave()" everywhere. Anyway I'm quite confident in this implementation.

    C / C++ / MFC question help

  • Too many WM_MOUSEWHEEL events issue
    T Tnarol

    Hi, My problem is that I sometimes receive dozens of WM_MOUSEWHEEL events for a single rotation step of the mouse wheel. Other events like WM_KEYDOWN don't have this problem, I received them only once for a pressed key. Normally I'm using this event in a CDialog inherited class and everything's works ok but the context here is slightly different. This time I had to create my window with "CreateWindowEx" so there's no CDialog inheritance and therefore I need to have my own message loop and message processing function. Can you have a look at them below and tell me if you see an explanation for my problem ? Thanks. Message loop : MSG msg; while (1) { PeekMessage(&msg, hWND, NULL, NULL, PM_REMOVE); TranslateMessage(&msg); DispatchMessage(&msg); if (msg.message == WM_QUIT) { break; } Sleep(100); } Message processing function : LRESULT CALLBACK WindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_CREATE: return 0; break; case WM_CLOSE: // windows is closing PostQuitMessage(0); return 0; break; case WM_DESTROY: PostQuitMessage(0); return 0; break; case WM_KEYDOWN: ProcessKeyStroke(MapVirtualKey(((UINT)lParam & 0x00ff0000) >> 16,1)); break; case WM_MOUSEWHEEL: { short zDelta = GET_WHEEL_DELTA_WPARAM(wParam); ProcessMouseWheel(zDelta); } break; default: return (DefWindowProc(hwnd, message, wParam, lParam)); break; } return 0; }

    C / C++ / MFC help oop question

  • EnterCriticalSection() exception issue
    T Tnarol

    It's just that a global variable is a simple kind of synchronization resource that can be seen and shared by several threads in a program. I could have this variable static in the class, but there are some strange things happening with static variables members of a class, if you use them very early in the program they are sometimes not yet created and it makes you crash. I don't have a logical explanation for this but that's my experience.

    C / C++ / MFC question help

  • EnterCriticalSection() exception issue
    T Tnarol

    led mike wrote:

    Is the purpose and use model of that class supposed to be evident? I don't get it.

    Yes, First at the beginning of your app you call InitCriticalSection() which is in fact InitializeCriticalSection() on a global g_ClassLock variable Then inside a function when you instantiate a ClassLock object it calls the constructor which locks the g_ClassLock variable using EnterCriticalSection( &g_ClassLock ) When the function return, the ClassLock object goes out of scope, so the destructor is called automatically and it does LeaveCriticalSection( &g_ClassLock ) Therefore the function has the g_ClassLock synchronization token for the duration of its' execution. Then at the end of the program DelCriticalSection must be called...and it does DeleteCriticalSection( &g_ClassLock ).

    C / C++ / MFC question help

  • EnterCriticalSection() exception issue
    T Tnarol

    Hi, I have a multithreaded program in which I use the following class object "ClassLock" the synchronize accesses : #ifndef CLASSLOCK_H #define CLASSLOCK_H extern CRITICAL_SECTION g_ClassLock; class ClassLock { public: static void InitCriticalSection(); static void DelCriticalSection(); inline ClassLock() { EnterCriticalSection( &g_ClassLock ); } inline ~ClassLock() { LeaveCriticalSection( &g_ClassLock ); } }; #endif I protect a function call by instantiating a ClassLock object at the beginning of the function : void MyFunc() { ClassLock l; ... } But sometimes, don't know why, an exception is thrown. How can I deal with this ? My idea would be the following modification, but I don't know if it's safe and smart : inline ClassLock() { while(!TryEnterCriticalSection( &g_ClassLock )) { } } Any other ideas ? Thanks

    C / C++ / MFC question help

  • Looking for a 2D graph display tool
    T Tnarol

    Hi Cédric, I already had a look at your project and even tryed it. The design is great for static data display but unfortunately it lacks real time (dynamic) plotting management features which makes it difficult for me to use as it is. For instance I would need to use the component as a scrolling scope but your component doesn't have the ability to remove and add some samples to the display without having to redraw all samples. This is not acceptable for me because I can have lots of samples and performance is critical. Thanks

    C / C++ / MFC c++ data-structures question

  • Looking for a 2D graph display tool
    T Tnarol

    Hi, I need a component working with VC++/MFC to plot 2D graphs. It should ideally be able to deal with real-time plotting (incremental datafeed, scrolling, dynamic scale... things like that). Can you suggest a good project doing this ? Thanks

    C / C++ / MFC c++ data-structures question

  • Can't run my program on other computers
    T Tnarol

    Sarath.even, you hadn't use any CLR APIs, you might have linked with those DLL.

    I'm not using the "/clr" option in the compile command line... Is there anything else that can make me link with unused DLLs ?

    C / C++ / MFC c++ help csharp dotnet visual-studio

  • Can't run my program on other computers
    T Tnarol

    WhiteSky wrote:

    maybe you used from services that are only in your system or dlls files

    I checked every single DLL loaded by my program (using "attach to process..." in visual studio) and copied them to the program directory.

    C / C++ / MFC c++ help csharp dotnet visual-studio

  • Can't run my program on other computers
    T Tnarol

    Hi, I have a basic Visual C++/MFC program written with VS .Net 2005 but that doesn't use .NET Framework. I tried to run it on another PC, and it didn't work although I had all the required DLLs in the same directory. It said something like "application could not initialize properly...". I tried to fix this by installing .Net Framework 2.0 (which did not solve the problem) and then using the setup wizard. This eventually worked but I don't know why. I want to be able to run my program from a USB key, without any installation or download. This should be possible since I'm not using the .NET Framework (at least not intentionnally...). I've never had this kind of problem with VS 6.0. Any idea of what I need to do with VS 2005 to make my program standalone ? Thanks

    C / C++ / MFC c++ help csharp dotnet visual-studio

  • Singleton class question
    T Tnarol

    Sarath.We should do the cleanup.

    Thanks. Is it OK to do the cleanup in a method of the same class ("destroyInstance()") as I suggested ? It seems a bit weird to me to destroy an class instance using a method inside it.

    C / C++ / MFC question performance

  • Singleton class question
    T Tnarol

    Hi, I have a a singleton class with a private instance pointer (pInstance) that is initialized with a dynamically created instance (using "new"). I'm just wondering what I have to do to ensure there is no memory leak when the class is no longuer used. Shall I create and call a "destroyInstance()" function in the class doing "delete pInstance; pInstance = NULL;" ?

    C / C++ / MFC question performance

  • Algorithm Request
    T Tnarol

    Be careful of the behaviour if x = 0 when using "log10". For the number of digits after "." I think you're going to have some problems, simply because the computer representation of floats and doubles of numbers do not exactly correspond to the value you gave. For instance it could happen that 123.3 actually corresponds to 123.29999999999999 as soon as it is stored as a float. So trying to guess the number of digits after "." makes no sense. You could maybe get around this if you limit the possible amount of decimal numbers to a well chosen value.

    C / C++ / MFC algorithms workspace

  • static member initialization order fiasco
    T Tnarol

    Ryan Binns wrote:

    You could also have GetConfigFile() set the file name if it hasn't been set

    Yes I had this idea already... but did not succeed at first... I had a look again after seeing your message and it seems the following code works : CString ConfigManager::GetConfigFile() { static bool bInit = false; if (!bInit) { ConfigManager::ConfigFile = DEFAULT_FILE; bInit = true; } return ConfigManager::ConfigFile; } Thanks

    C / C++ / MFC c++ html com help

  • static member initialization order fiasco
    T Tnarol

    Cedric Moonen wrote:

    Yes, but... Why use a class then ?

    Just to gather things that deal with the same subject...

    C / C++ / MFC c++ html com help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups