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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
L

Luis E Cuadrado

@Luis E Cuadrado
About
Posts
46
Topics
19
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • problem using CDialog::Create, assert error
    L Luis E Cuadrado

    I'm going to try Tim's suggestion. As soon as I find something, I will post back the results. Thanks for your replys. Luis E. Luis E. Cuadrado :0)

    C / C++ / MFC help debugging question

  • problem using CDialog::Create, assert error
    L Luis E Cuadrado

    Hi DavidCrow, Yes, I stepped through the Create() code. The assertion is comming in the AfxFindResourceHandle() function. I included the portion of the code where the assert error comes and I pointed out where the assert error occurs. Aparently the value pModuleState->m_bSystem returned by AfxGetModuleState() is causing the assert error. Here is the code.

    HINSTANCE AFXAPI AfxFindResourceHandle(LPCTSTR lpszName, LPCTSTR lpszType)
    {
    	ASSERT(lpszName != NULL);
    	ASSERT(lpszType != NULL);
    
    	HINSTANCE hInst;
    
    	// first check the main module state
    	AFX_MODULE_STATE* pModuleState = AfxGetModuleState();
    	if (!pModuleState->m_bSystem)
    	{
    		hInst = AfxGetResourceHandle(); //-->ASSERT OCCURS HERE!!!
    		if (::FindResource(hInst, lpszName, lpszType) != NULL)
    			return hInst;
    	}
    .
    .
    .
    

    I hope this helps. Before I forget, thanks for your reply David Luis E. Cuadrado :0)

    C / C++ / MFC help debugging question

  • problem using CDialog::Create, assert error
    L Luis E Cuadrado

    Hello everybody, Here is my problem. I'm trying to display a dialog and in the Create() function I'm getting an assert error. I dig up through the debugger and I found out where I'm getting the assert error is in AfxGetResourceHandle(). Here is my code:

    int APIENTRY WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
    {
     	// TODO: Place code here.
    	CMainDlg *mainDlg = new CMainDlg(); //Base class is a CDialog
    	BOOL bRet = mainDlg->Create(IDD_MAIN_DIALOG, NULL); //-->I'm getting the assertion error here!
    	if (bRet != 0)
    	{
    		mainDlg->ShowWindow(SW_SHOW);
    	}
    	else if(bRet == 0)
    	{
    		AfxMessageBox("Error Creating Dialog");
    	}
    
    	return 0;
    }
    

    As you noticed, all I'm trying to do is to display a dialog. Is there anything that I have to set in advance before I create the dialog and display it? Any answer is more than welcome. Best regards, Luis E. Cuadrado :0)

    C / C++ / MFC help debugging question

  • using cin.getline() with string
    L Luis E Cuadrado

    Hola Joaquín, Thank you for your response. I did exactly what you told me and it works. Thank you for pointing me out to that Microsoft site and for your help. Another question that I have is, if I want to do that in a loop. Do I need to flush or wipe-out the stream that I'm using? The reason that I'm asking is that I put everything in a loop except the cout statements and the loops keeps going and it doesn't stop. I step over the code and I noticed that there still data, aparently in the stream. Have you experience this before? Thanks, Luis E. Luis E. Cuadrado :0)

    ATL / WTL / STL help question

  • using cin.getline() with string
    L Luis E Cuadrado

    Thanks for replying Kuphryn. I gave it a try and the program complies but when I run it, the variable where I store the value using the std::getline() function doesn't show up when I use cout.

    #include <iostream>
    #include <string>
    using namespace std;
     
    void main()
    {
    string itemID;
    string Desc;
    cout << "Enter ID: ";
    cin >> itemID;
    cout << "Enter Description: ";
    getline(cin, Desc);
    
    cout << "itemID: " << itemID << endl;
    cout << "Desc: " << Desck << endl;
    
    } 
    

    This is the output that I got.

    Enter ID: 222
    Enter Description: matches
    itemID: 222
    Desc:

    I'm asuming that there are some kind of garbage collecting thing that I have to do here, is it? Let me know what you think. Thanks for your help, Luis E. Luis E. Cuadrado :0)

    ATL / WTL / STL help question

  • using cin.getline() with string
    L Luis E Cuadrado

    Hello everybody: I was wondering if ther is a way to use the cin.getline() function when you use string objects. With the code snipet below I get the following error:

    error C2664: 'class std::basic_istream > &__thiscall std::basic_istream >::getline(char *,int,char)' : cann
    ot convert parameter 1 from 'class std::basic_string,class std::allocator >' to 'char *'
    No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
    Error executing cl.exe.

    hwproject.exe - 1 error(s), 0 warning(s)

    I always encounter this problem and I don't know what to do to solve this. Is there a better way to do this with string objects? Can you tell me what I did wrong with the code below? Any answer is more than welcome. #include <string> #include <iostream> using namespace std; void main() { int itemNum; string Desc; cout << "Enter Item Number: "; cin >> itemNum; cout << "Enter Description: "; cin.getline(Desc, sizeof(Desc), (char)"\n"); } Luis E. Cuadrado :0)

    ATL / WTL / STL help question

  • Compiling a Visual C++ 6 in the command-line
    L Luis E Cuadrado

    Hello, Just what I need. I tried and it works. Thank you very much for you help. Best regards, Luis E. Cuadrado :0)

    C / C++ / MFC c++ question

  • Compiling a Visual C++ 6 in the command-line
    L Luis E Cuadrado

    Hello everybody, This might sound like a stupid question, but I can't find anything. Do you guys know how I can compile a Visual C++ application in the command-line? Is there any place on the web where I can find information about that? Any answer is more than welcome. Best regards, Luis E. Cuadrado :0)

    C / C++ / MFC c++ question

  • Adding URLs in a CDialog
    L Luis E Cuadrado

    Hello Everybody, Is there a way to put text in a dialog that the user can click and load a IE window with the URL? I tried a couple of things and nothing works. Any suggestions? Any answer is more than welcome. Best regards, Luis E. Cuadrado :0)

    C / C++ / MFC question

  • Is it possible to insert a new line (\n) in a tool tip?
    L Luis E Cuadrado

    I found a way! Where you create the CToolTipCtrl and and you call the Create() method, you had the following line: m_ToolTip->SendMessage( TTM_SETMAXTIPWIDTH, 0, 300); Then in the AddTool() method, you can put \n's and it will add a new line to the tool tip. The code looks pretty much like this: if ( m_ToolTip == NULL ) { m_ToolTip = new CToolTipCtrl; m_ToolTip->Create(this); m_ToolTip->SendMessage( TTM_SETMAXTIPWIDTH, 0, 300); } m_ToolTip->AddTool(this, "One line\nSecond Line\nThird line"); m_ToolTip->Activate(TRUE); I did this and it worked. Best regards, Luis E. Cuadrado :0)

    C / C++ / MFC question

  • Is it possible to insert a new line (\n) in a tool tip?
    L Luis E Cuadrado

    Hello everbody: I was wondering if it is possible to have more than one line in the string that is going to be displayed in a tool tip? I gave it a try with the following code, but is displayed all in one line and there is a small square in between the two strings that I want to display: CString displayLine; CString idString; idString.LoadString(IDS_TT_DCSRAW); displayLine.Format("%s\nHi Res", idString); . . . m_ToolTip->AddTool(this, (LPCTSTR)displayLine,rFileTypeCoord, 1); Is this a Tool Tip attribute that I have to set? Is there another way to put the new line character? Any answer is more than welcome. Best regards, Luis E. Cuadrado :0)

    C / C++ / MFC question

  • Server Busy windows dialog
    L Luis E Cuadrado

    Hello Everybody: Lately I'm getting a windows message box that it says: "Server Busy This action cannot be competed because the other program is busy. Choose 'Switch To' to activate the busy program and correct the probelm" Then it has 3 buttons, one says Switch To, the other one says Retry and the last one is a disabled button that says Cancel. This Server Busy message box doesn't show up constantly. It's happening when I call another application using another one. The code that I'm noticing the problem looks like this: COleException *e = new COleException; CLSID clsid; if (CLSIDFromProgID(OLESTR("OtherApp"), &clsid) != NOERROR) { AfxMessageBox(IDS_ERR_LOOKUP_PROGID); return; } // create the Ole Driver object if not already done if (m_otherApp == NULL) { m_otherApp = new IOtherApp(); if (m_otherApp == NULL) return; } // if not dispatch ptr attached yet, need to create one if (m_otherApp->m_lpDispatch == NULL) { try { BOOL sts = m_otherApp->CreateDispatch(clsid, e); if (!sts) { throw e; //AfxMessageBox(IDP_UNABLE_TO_CREATE); //EndDialog(IDABORT); //return; } } Is there a way to make that "Server Busy" message box go away? Anything is more than welcome. Best regards, Luis E. Cuadrado :0)

    C / C++ / MFC com sysadmin help question

  • A weird behavior of a CScrollView
    L Luis E Cuadrado

    Hello Everybody: This is the weirdest thing that I experienced with MFC. In a project that I'm working, there is a class that is derived from a CScrollView that displays images. When I run the program and the CScrollView is visible on the screen, sometimes it shows up as a text editor. It stays as an text editor and the images shows up. There are some occasions that the text editor just stays there. By any chance any of you guys experienced this before? Any place that you guys can suggest that I can start looking? It's been hard to spot because the code is written by someone else. I tried in the CScrollView's OnInitialUpdate and I don't find anything. This is happens in a Win2k and a WinXP machine. Any answer is more than welcome. Best regards, Luis E. Cuadrado :0)

    C / C++ / MFC c++ question

  • Disabling buttons with bitmaps
    L Luis E Cuadrado

    plain-vanilla CButton...that was a good one :laugh: Well, I think is a CButton because I added a member varialbe using Class Wizzard, and the button has an object ID. To be honest, I didn't wrote the code to make the button enabled and working. Someone else did it and is not with us anymore. I worked with the regular buttons before, but not with those that have bitmaps on it. I was looking arround the code and this is what I think the other person did: m_autoBitmap.LoadBitmap(IDB_AUTO); ::SendMessage(::GetDlgItem(m_hWnd, ID_AUTO_BTN), BM_SETIMAGE, IMAGE_BITMAP, (long)m_autoBitmap.operator HBITMAP()); Does this helps? If you need anything else let me know. Thanks again Alvaro, Luis E. Cuadrado :0)

    C / C++ / MFC graphics tutorial question

  • Disabling buttons with bitmaps
    L Luis E Cuadrado

    Hi: Does anyone know how to disable a button that has a bitmap on it? I'm trying with EnableWindow(TRUE/FALSE) and it disables the button but the bitmap it's gone. Any ideas? One more thing, the buttons are in a dialog. Any answer is more than welcome. Have a good day, Luis E. Cuadrado :0)

    C / C++ / MFC graphics tutorial question

  • Getting Assert error with CFileDialog::DoModal
    L Luis E Cuadrado

    I checked and I found out that the person that wrote the code, was setting the OFN_EXPLORER tag. I commented that part out and it doesn't make a diference. It still fails the assertion. Thanks for your help!! Best regards, Luis E. Cuadrado :0)

    C / C++ / MFC help question

  • Getting Assert error with CFileDialog::DoModal
    L Luis E Cuadrado

    No problem. This is pretty much how the source file looks like: CFileDialog openDlg; . . . if (lastFileOpenPath.GetLength() > 0) { openDlg.m_ofn.lpstrInitialDir = (LPCTSTR)lastFileOpenPath; } int nResult = openDlg.DoModal(); Thanks, Luis E. Cuadrado :0)

    C / C++ / MFC help question

  • Getting Assert error with CFileDialog::DoModal
    L Luis E Cuadrado

    It is ASSERTing in the DoModal function in the DLGFILE.CPP. The ASSERT comes out after selecting a file from the Open Dialog. This is where is ASSERTing on in the DLGFILE.CPP: if (nResult) ASSERT(pThreadState->m_pAlternateWndInit == NULL); <-- HERE pThreadState->m_pAlternateWndInit = NULL; when I check the Developer Studio's call stack, it's comming from here: if (lastFileOpenPath.GetLength() > 0) { openDlg.m_ofn.lpstrInitialDir = lastFileOpenPath; } int nResult = openDlg.DoModal(); <--- HERE I hope this helps. Thanks, Luis E. Cuadrado :0)

    C / C++ / MFC help question

  • Getting Assert error with CFileDialog::DoModal
    L Luis E Cuadrado

    By the if...loop you mean the following? if (lastFileOpenPath.GetLength() > 0) { openDlg.m_ofn.lpstrInitialDir = lastFileOpenPath; } If so, yes. I did a step over and I was able to see it being executed. After it comes out of the if then the DoModal function throws and assert error. About lastFileOpenPath, yes is pointing to a directory in the machine. I'm able to open the file selected by the open file dialog. But I have to click Ignore when I get the assert error. Thanks, Luis E. Cuadrado :0)

    C / C++ / MFC help question

  • Getting Assert error with CFileDialog::DoModal
    L Luis E Cuadrado

    Hello everybody: Everytime that I call the function CFileDialog::DoModal I'm getting an Assert error. This is what I have in my code: if (lastFileOpenPath.GetLength() > 0) { openDlg.m_ofn.lpstrInitialDir = lastFileOpenPath; } int nResult = openDlg.DoModal(); Is there something that I'm missing? Is any of you guys had this problem before? Any answer is more than welcome. Have a good day!!! Luis E. Cuadrado :0)

    C / C++ / MFC help question
  • Login

  • Don't have an account? Register

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