In my program I need to use some mathematical (unicode) symbols like sigma, square root, integral, and so on. For some reason only some of the unicode works while others not. For example, I have an array Names and a CCombobox m_combo, and a loop to add the strings in the array to the combo box.
static const CString Names ="a","=",0x221A,0x222B,0x2211,0x2212, 0x223B};
for(int i=0; i<7; i++)
The combo box correctly displayed "a", "=", square root (0x221A), integral (0x222b),sigma (0x2211), minus sign (0x2212), but it shows only a square box for 0x223b instead of showing the symbol. This only happens to many other unicode characters.
Why some symbols can be correctly displayed while others not? Also how can VC++ convert a wchar_t into a CString automatically?
Are you using the CListCtrl? If so remember that you must first have the columns present if you use a CHeaderCtrl. Once you have that you can use the following code
int iRowRet = m_LISTCONTRL.InsertItem(m_LISTCONTRL.GetItemCount(),strText);
I think the problem is somehow related to the fact that hWnd is NULL in my new dialog object. I have no clue however how to initialize hWnd.
Please, can't someone just try to make a dialog based app, and then fire up a new dialog from the main frame. And if you can assign values to variables in this new CDialog, please tell me how you did....
I created a small test project and it works OK. This is what I did:
1. Create a standard Dialog-based MFC app
2. Add a new dialog resource to the project (IDD_DIALOG1)
3. Put a listbox on the new dialog
4. Open ClassWizard and coose to create a new CDialog class for new dialog resource (CDialog1).
5. With ClassWizard, add a CListBox member for the list (m_wndList)
6. Add a button to the main dialog and add an OnClick handler like this:
m_wndList.AddString("String to add"); // Assertion here? Call the X Files immediately:-)
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
Try this, and if you still get an assertion at CListBox::AddString(), something is very, very strange.
I'm trying to use the printer port to do some simple I/O operations in windows 2000. However, as I quickly learned direct IO is a no-no with the NT kernel. I've tried to find out how I can accomplish just reading/writing single bytes to the port but all I've managed to find is shareware device drivers that accomplish this. For my purpose a driver is overkill. I've read that I could use CreateFile() to read and write to the port, but how would I specifically read the Control and Status parts of the printer port? Reading those two ports is essential. I really appreciate any help/suggestions. Thanks a lot!
i'm making a chat program where the user inputs
text in a multiline edit box and it is added to a buffer
declared as a character array which is then sent
to another edit box set as read-only for display.
i need to separate messages of different users
by a line or two.
The problem is that '\n' comes out as a square.
i have tried to use ToAscii(VK_RETURN...) but the
some weird character came up. i have also tried to
send an extra VK_RETURN to the user input edit box before i
GetDlgItemText(), but for some reason it comes up
after the text is read and cleared, so the edit box
ends up blank with the cursor on the second line.
is this possible, or should i try to make my buffer
Anybody know where I can find a good example of creating docking windows in strait C? Cristi Posea has excellant source for MFC (http://www.codeproject.com/docking/sizecbar.asp), but I'd like to know what's going on underneath, and MFC source is kind of a pain to step through.
I'm using SHFileOperation to delete folders, as shown in the following code. However, there seems to be a problem with spurious "file in use" errors when I call this function on most folders in my system. These directories don't have any special properties that I can see via browsing, so I can't understand when the command fails.
Is there some catch or trick in this? Win2K, SP1, VC++ 6.
// Get the path
ZeroMemory(szOldPath, sizeof(szOldPath)); // SHFileOperation requires a double-null terminator
// Set up the file op
fileOp.hwnd = AfxGetMainWnd()->GetSafeHwnd();
fileOp.wFunc = FO_DELETE;
fileOp.pFrom = szOldPath;
fileOp.pTo = "\0\0"; // NULL;
fileOp.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION;
fileOp.fAnyOperationsAborted = FALSE;
fileOp.hNameMappings = NULL;
fileOp.lpszProgressTitle = NULL;
I’m trying to write 3 strings out to a text file but I need each string to be on a separate line.. Here is what I have tried..
CFile::modeCreate + CFile::modeWrite))
//Write out the full string
//Close the file
I've tried every combo of "\n" "\r" etc..
It still writes out the 3 strings in one continuous line in the text file..
I don't even have a Window menu... MFC places it on the bottom of my second-last menu... Even if this menu's name is "Test" for example... and my menu items names "Test1", "Test2", ... The Window list is put always on the bottom of them...
Do you understand the difference between menu item name and menu item ID? Changing the names will not help. If you have menu containing items with identifiers like ID_WINDOW_xxx, the window list will be appended. You have to change menu item identifiers.
I do! I don't have a menu which has an ID that starts with ID_WINDOW_ ... As a matter of fact, MFC puts the window list on the "Test" menu's bottom... Which has the ID's: ID_TEST_TEST1 and ID_TEST_TEST2. My Child windows are created through the CMDIChildWnd class' Create method...
CSettingsDlg m_settDlg; // Derived from CMDIChildWnd
Nope, non of these three... If you have a few seconds time, I have send you a VERY small test-case (created within a few minutes from scratch using the MFC wizard) by mail (If you're upset for this, I'm sorry, but I'm quite desperate)...
Can you please tell me how to hide/delete the window popup menu from the main menu if I am working with Doc/ View application? Thats really urgent, I am using the code like
CMenu *menuVault = this->GetMenu();
::DeleteMenu(menuVault->GetSafeHmenu(),9,MF_BYPOSITION);//9 is the position of Wondows menu
everything seems to be ok but menu bar is not getting refreshed or redrawn..... what could be worng????
As a CTreeCtrl is expanded and contracted, the area covered by the tree varies. Anyone know how I can find / calculate the size of this area. I don't just want to know the area of the CTreeCtrl window, but the area covered by the actual tree. Anyone got any ideas please?
I'd like to modify some of the code on this site which is a drop down ctreectrl, but the drop down window is of fixed size. I'd like to make the drop down window vary in size according to the size of the actual tree.
Seems that you have to do this 'manually' - there's no single function.
1) call CTreeCtrl::GetFirstVisibleItem. The name says it all
2) in the loop, call CTreeCtrl::GetNextVisibleItem until it returns NULL. For each item, determine its rectangle using CTreeCtrl::GetItemRect. UnionRect will combine items' rectangles into one.
OK, so I made myself an MFC Extention dll (this time I used MFC as shared library and all, everything looks ok), but I've still got some problems here...
I want to export a couple of classes from my extention DLL and things go wrong in de destructors.... For example, I tried the following code:
// --- This one goes OK ---
// CMyObject has a couple of members: strings, pointers and numbers
CMyObject * pNew = new CMyObject();
// --- This one stinks ----
// CMyComplexObject has a couple of protected members, which are pointers to CMyObject instances
// CMyComplexObject creates the instances of the members in the constructor with 'new' and deletes them in
// the destructor with 'delete'.
CMyComplexObject * pNew = new CMyComplexObject(); // This goes correctly
delete pNew; // Application crashes on the delete of it's own members (the ones it made with 'new' in the constructor)!