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
N

Newbie00

@Newbie00
About
Posts
99
Topics
8
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Multithreading
    N Newbie00

    if you want to manage the order of working threads you have to use something to tell them, if it's their turn to work. critical sections are for keeping common data thread safe. Only one thread can enter critical section at given time. but there are no rules which thread can do it in cs case. It depends on system and threads state. If you want to set order you can use WaitForSingleObject or WaitForMultipleObjects with SetEvent method to let threads work when it's their time.

    C / C++ / MFC performance question

  • problem on show messagebox on ON_EN_CHANGE of edit control.
    N Newbie00

    1 Is the problem present, if message box is still opened? 2 Or Is the problem present even after closing message box? If 1 is true and 2 not, I think that you have blocked system clipboard with your message box. You opened modal dialog (msgbox) during OnPaste msg and it cannot finish it's work untill messagebox is closed. If it cannot finish it's work, the system clipboard cannot be released. If clipboard is not released, the ctrl+c, ctrl+v doesn't work in whole system.

    C / C++ / MFC help question

  • scrollview issue on win7 environment
    N Newbie00

    Hello, In my case the problem was just with screen refreshing on Win7. Updating graphics card driver or turning Windows AERO off on user's computer solved the problem. So I think my case was different from yours. The only one thing is the same in our cases: WinXP worked fine, Win7 did not. If I undarstand your app correctly, you are creating many GDI objects (many Cwnd obj.). It is a surprise for me, because normally there is a limit for GDI in application. If you reach that limit, method: CWnd::Create() fails. The value of GDI count is written in Windows registry. Unfortunately I don't remember the regkey. But I think this also not your case, since you have got probles with controls overlapping from certain point of scroll pos. Maybe the problem is not with ScrollBar, but with scrolled out CScrollView. Maybe you have reached the end of CScrollView and your application is trying to draw all controls at the end of CScrollView? I think you can try to change your mechanics in app. Do something like this: Do not let your application to scroll View so far (above 32k). It is not necessary. Try to hide/delete controls, if are scrolled out from visible part of View and show/create controls, which has to be shown after scrolling.

    C / C++ / MFC c++ visual-studio csharp design xml

  • scrollview issue on win7 environment
    N Newbie00

    In my case there were just texts too. The problem was not with advanced 3d graphics, but with srolling many controls containing simple texts. 8 columns and 20 rows each filled with one control, scrolled on Win7 with Aeoro turned on on some Intel grapcics chipset caused overlapping. Could you show us this special method? What does it do, that problem is solved for Win XP? Maybe some methods are not supported by Win7. Or Win7 uses other dlls version, which are not good for your solution from WinXp.

    C / C++ / MFC c++ visual-studio csharp design xml

  • glut.h header package doesnt work
    N Newbie00

    adding only header (*.h) is not enough. You have to also add proper lib or cpp to your program in order to linker could see definitions of functions you are using in your program. To add lib, see the linker options, there has to be some place to include additional libraries.

    C / C++ / MFC c++ help

  • scrollview issue on win7 environment
    N Newbie00

    Hello, What does it mean: "The vertical scroller or scrollbar does not work properly"? Does it mean you cannot use it? Is it disabled? or just screen is not refreshed properly? If I understood the effect on Win7: "overlapping controls" maybe the problem is with graphics card? I know cases from my application, that on some poor graphics cards on Win7 with AERO turned on scrolling rows containing many editable controls caused strange screen effects. The solution was to update graphics card driver or turn the AERO off. It helped in all cases.

    C / C++ / MFC c++ visual-studio csharp design xml

  • Access structure variable value using string representing variable's name in C++.
    N Newbie00

    If you want to use c++ make a class instead of struct:

    class CStudentInfo
    {
    public:
    enum EVal
    {
    erollnumEVal,
    emark1EVal,
    emark2EVal
    };

    int GetValue( EVal eVal )
    {
    int iRetVal = 0;

    switch( eVal )
    {
    case erollnumEVal:
    iRetVal = rollnum;
    break;

    case emark1EVal:
      iRetVal = mark1;
      break; 
    
    case emark2EVal:
      iRetVal = mark2;
      break; 
    
    default:
      ASSERT( FALSE );
      break; 
    

    }

    return iRetVal;
    }

    private:
    int rollnum;
    int mark1;
    int mark2;
    }

    But why do you need something like this? couldn't it be just simple:

    class CStudentInfo
    {
    public:

    int Getrollnum()
    {
    return rollnum;
    }

    int Getmark1()
    {
    return mark1;
    }

    int Getmark2()
    {
    return mark2;
    }

    private:
    int rollnum;
    int mark1;
    int mark2;
    }

    C / C++ / MFC c++ design help

  • DoModal in CWnd::PreTranslateMessage( MSG *pMsg )
    N Newbie00

    This program is already complicated :D Now I am trying to avoid crashes xD I could use EN_CHANGE, if I could prevent just typing. But what about pasting with ctrl + v illegal text? Should I delete it in EN_CHANGE automatically? Other case is, that I have to also read data from editable controls, put it to internal buffer and set "Modified" flag for saving database record later. If data is illegal, I cannot put it to the buffer and set this flag. For simple edits it os ok. But there are also RichEditCtrl controls with OLE and a lot of text. I do not want to copy all text with OLE to the buffer each time EN_CHANGE comes.

    C / C++ / MFC c++ question

  • About preventing memory leaks
    N Newbie00

    Why you are using "delete(settingsFile);" instead of "delete settingsFile;". What does it mean? I think you should also close settings file before deleting it. And if the settingsfile->open() fails you will get another memmory leaks, because you are leaving function without deleting settingsfile.

    C / C++ / MFC help com tools performance question

  • DoModal in CWnd::PreTranslateMessage( MSG *pMsg )
    N Newbie00

    Unfortunately I cannot use OnChange. It is to early to disturb user. I have to wait untill user finishes typing. EN_CHANGE is sent after each pressed key and I cannot save data from control to internal buffer during typing. I want to do it, if user decides to leave edit control. I have also investigated this MSG *pMsg deeper and it occured that: If I let pumping messages (f.e with modal messagebox), I always have to return TRUE in PreTranslateMessage. Saving first message and forwarding it at the end has no sence, because the whole messaging process is disturbed any way. Here is example of situation, for which my solution with saving *pMSG won't help: WM_LBUTTONDOWN -> WM_LBUTTONUP pair is very sensitive here. If I put messagebox between WM_LBUTTONDOWN and WM_LBUTTONUP in PreTranslateMessage it causes WM_LBUTTONUP to run for mouse point from the [OK] button on the messagebox and not for the original coordinates. So code from CFirstClickedArea::OnLButtonUp() will not be run. So I think, I have to return always TRUE and I have no choice, if I want to use PreTranslateMessage with DoModal.

    C / C++ / MFC c++ question

  • DoModal in CWnd::PreTranslateMessage( MSG *pMsg )
    N Newbie00

    I cannot let to run OnKillFocus if control has no valid value, because OnKillFocus is too late. It is out of my control. Let me show you some example: I have a toolbar also. If somebody presses toolbar button OnCommand is running. Let say it is saving the document. Before saving I have to recalculate it and then save. Recalculating depends on the values in Edit. If Edit is not valid I have wrong calculations. Unfortunately pressing this toolbar buton doesn't cause KillFocus for my Edit. I have to use SetFocus to the edit's parent in order to make KillFocus for my edit to run, before I make recalculation. I don't like this solution. I have many similar problems with validating data in OnKillFocus, so I need to handle all actions before OnKillFocus and before OnLButtonDown, OnCommand, etc of given buton. I do not want to change all possible handlers in my app so I choose PreTranslateMessage. Sometime I return TRUE in PreTranslateMessage for example in order to not let the app for saving document, if user is in serious trouble with his already typed data.

    C / C++ / MFC c++ question

  • DoModal in CWnd::PreTranslateMessage( MSG *pMsg )
    N Newbie00

    Hello, I need to verify content of my edit control before I let it to loose focus. To do so I wrote my PreTranslateMessage like this:

    BOOL CMyFrameWnd::PreTranslateMessage( MSG *pMsg )
    {
    BOOL bMessageHandled = FALSE;

    switch( pMsg->message )
    {
    case WM_LBUTTONDOWN:
    {
    if( ::GetFocus == MyEditWnd )
    {
    if( !IsContentOfMyEditWndOK )
    {
    ShowMessageBox( "You cannot change value");
    //ShowMessageBox has got DoModal inside, which pumps messages.
    //Unfortunately it causes my *pMsg parameter to be changed.
    }
    }
    break;
    }
    }
    if( !bMessageHandled )
    {
    bMessageHandled = CFrameWnd::PreTranslateMessage( pMsg ); //I get assertion has failed here, because I am sending pMsg->Hwnd changed with 'ShowMessageBox'
    }

    return bMessageHandled; //I want to show messagebox and let WM_LBUTTONDOWN to be processed, because I do not want to trap focus in my Edit. So I am returning FALSE here. But it has no sence since the pMsg has changed. It is no longer WM_LBUTTONDOWN.
    }

    In order to be able to show modal dialog in PreTranslateMessage and after it forward WM_LBUTTONDOWN I would like to do something like this:

    BOOL CMyFrameWnd::PreTranslateMessage( MSG *pMsg )
    {
    BOOL bMessageHandled = FALSE;
    MSG oRememberMsg;

    switch( pMsg->message )
    {
    case WM_LBUTTONDOWN:
    {
    if( ::GetFocus == MyEditWnd )
    {
    if( !IsContentOfMyEditWndOK )
    {
    oRememberMsg = *pMsg;
    ShowMessageBox( "You cannot change value");
    *pMsg = oRememberMsg; //now pMsg is WM_LBUTTONDOWN again
    }
    }
    break;
    }
    }
    if( !bMessageHandled )
    {
    bMessageHandled = CFrameWnd::PreTranslateMessage( pMsg ); //I am not getting assertion has failed, because pMsg->HWnd is correct now (the same as at the beginning)
    }

    return bMessageHandled; //Now I am forwarding my catch WM_LBUTTONDOWN and my Edit loses focus
    }

    But I am not sure if my code is ok from MFC structural point of view. Can I manipulate with MSG *pMsg parameter as I described above? I tried it and it seems to work, but I don't know... Does it make some side effects? Is something I am missing here? How do you think?

    C / C++ / MFC c++ question

  • CRichEditCtrl and 'what you see is what you get' problem
    N Newbie00

    Hello, I use several controls with the CMainFrame=>CView. These controls are for putting different values like 'amount', 'price', and 'text'. There is also possibility to print all CView content. And the problem is with setting 'what you see is what you get' for CRichEditCtrl. My CRichEditCtrl is calculated to have 8 cm + some offset width, because text printed, and print previewed has also 8 cm width. I would like the text in my CRichEditCtrl looked identical as on the printout. So I use CRichEditCtrl::SetTargetDevice(...) in order to set: 1. Printer DC 2. line width calculated as 8 cm. After I used SetTargetDevice the word wrapping is the same as on the printout, but there is still very big problem. I mean the text is very often partly shifted out of the CRichEditCtrl in the horizontal view. It looks like CRichEditCtrl didn't have enough space to contain all text width, but it is not true. It really has 8 cm + offset. The line set with SetTargetDivice has also 8 cm width. So I don't understand why the CRichEditControl does not contain whole text width. I checked the same text, with the same font setting, with the same margin in the MS Word, and in MS Word everything looks fine. Whole text is well fitted. My question is: Did i miss some setting? What am i doing wrong here? Or maybe I should get "what you see is what you get" in some other way? I'm including printscreen showing the problem: http://rapidshare.com/files/157373743/Screen.png[^] Regards.

    C / C++ / MFC question com help

  • char * to String^
    N Newbie00

    Well it's quite simple: You can create String objects with passing char* to the String constructor. 'Text' is something like pointer. gcnew is something like new in c++ but a little bit smarter. So all we have to do is just create new String^ object with szData as value instead of "" ( String is initialized with "" string normally ).

    Managed C++/CLI csharp c++ visual-studio tutorial

  • char * to String^
    N Newbie00

    How about something like this? textBox->Text = gcnew String(szData);

    Managed C++/CLI csharp c++ visual-studio tutorial

  • OpenGL and VC++ 2005 EE
    N Newbie00

    Hi, i'm not sure if i've chosen correct place for my post, but I'm writing an app in VC++ 2005 EE which is going to display some 3D figures on System::Windows::Forms::Panel^ panel The problem: I've written my own class which handles all OpenGL stuff. So all I have to do is: Create new 3D figure object, and draw it with panel's Paint method. Constructor needs panel's HWND, so i did something like this: TFigure *Figure; //pointer to my base class objects Figure = new TCuboid( (HWND)panel->Handle.ToPointer() , panel->Width, panel->Height, 3, 3, 7 ); But this solution doesn't work properly. When i'm trying to initialize OpenGl machine with this code (inside TCuboid construcor): m_gHDC = GetDC( hwnd ); //identifier (window HWND) SetupPixelFormat(); m_hRC = wglCreateContext( m_gHDC ); //identifier (OpenGL graphic context) the variable: m_hRC is NULL and it shouldn't be. GetLastError() returns 2000, which is ERROR_INVALID_PIXEL_FORMAT. I've tried my class code with other IDE and all was fine. This is SetupPixelFormat() definition: void TFigure::SetupPixelFormat() { int nPixelFormat = 0; PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0, 16, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 }; nPixelFormat = ChoosePixelFormat( m_gHDC, &pfd ); SetPixelFormat( m_gHDC, nPixelFormat, &pfd ); } ChoosePixelFormat( m_gHDC, &pfd ); returns 7 Can somebody help me please?

    Graphics help c++ visual-studio graphics game-dev

  • How to get HWND from System::Windows::Forms::Panel^ panel [modified]
    N Newbie00

    I think i'm passing correct DC. void TFigure::SetupPixelFormat() { int nPixelFormat = 0; PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0, 16, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 }; nPixelFormat = ChoosePixelFormat( m_gHDC, &pfd ); SetPixelFormat( m_gHDC, nPixelFormat, &pfd ); } ChoosePixelFormat( m_gHDC, &pfd ); returns 7. -- modified at 13:35 Monday 15th October, 2007

    Managed C++/CLI help c++ visual-studio graphics game-dev

  • How to get HWND from System::Windows::Forms::Panel^ panel [modified]
    N Newbie00

    how do you know what 2000 means? :O That could be a clue, but it's worse than i thought :O I have no idea why such strange error occures. I've tried this code with C++ Builder 6.0 and everything was ok :O There was no ERROR_INVALID_PIXEL_FORMAT

    Managed C++/CLI help c++ visual-studio graphics game-dev

  • How to get HWND from System::Windows::Forms::Panel^ panel [modified]
    N Newbie00

    Yeees :] hmmmmmmmm I've tried to use GetLastError() with FormatMessage() like this: LPVOID lpMsgBuf; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR) &lpMsgBuf, 0, NULL ); But an exception occures: An unhandled exception of type 'System.Runtime.InteropServices.MarshalDirectiveException' occurred in Figury.exe Additional information: Cannot marshal 'parameter #7': Pointers cannot reference marshaled structures. Use ByRef instead. GetLastError() returns 2000, i don't know what to do :[

    Managed C++/CLI help c++ visual-studio graphics game-dev

  • How to get HWND from System::Windows::Forms::Panel^ panel [modified]
    N Newbie00

    Yes it is non-NULL too.

    Managed C++/CLI help c++ visual-studio graphics game-dev
  • Login

  • Don't have an account? Register

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