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
D

David YueZuo

@David YueZuo
About
Posts
8
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How to set text color in CRichEditCtrl?
    D David YueZuo

    LOL..thx for your suggestions, i will keep that in my mind. Unfortunately, my team have to use VC++ since they started using it at 1998. Maybe I should get my job changed, how about become to a java developer, would be better? hahaha...:)

    David Zuo

    C / C++ / MFC question c++ help tutorial

  • How to set text color in CRichEditCtrl?
    D David YueZuo

    I tried m_richEditCtrl.SetSel(length, newLength - 1 ), but it still doesn't work well. Actually, what I found is RichEdit2 considers '\n' as two symbols - "\r\n", so if we use m_richEditCtrl.SetWindowText("12345\n"); int length = richEditCtrl.GetWindowText(); // the actual value of length equals to 7, not 6. Again, if we have m_richEditCtrl.SetWindowText("12345\n67890"); int length = richEditCtrl.GetWindowText(); // equals to 12, not 11. richEditCtrl.SetSel(0, 6); m_richEditCtrl.SetSelColor(Red); // pseudo-code m_richEditCtrl.SetSel(7, -1); // This function doesn't set correct text m_richEditCtrl.SetSelColor(Blue); // pseudo-code /// The actual text color is, "123456" is red, "7890" is blue /// If you put more letters and '\n' into the string, you will find the text color shifts more than you think but, if we use m_richEditCtrl.SetWindowText("12345\n67890"); int length = richEditCtrl.GetWindowText(); // equals to 12, not 11. richEditCtrl.SetSel(0, 5); m_richEditCtrl.SetSelColor(Red); // pseudo-code m_richEditCtrl.SetSel(6, -1); m_richEditCtrl.SetSelColor(Blue); // pseudo-code /// program now works well What I found is, the number of the selected text SetSel() function shifts that equals to the number of '\n' being used in the string. Is it weird? Most time I cann't understand why Microsoft still recommand us to use Visual C++, MFC is too old to use. They always use very weird way to do some crazy things. Doesn't make any sense! Furthermore, so manys bugs are found in MFC library, it seems Microsoft never tested their APIs before they released them.

    David Zuo

    C / C++ / MFC question c++ help tutorial

  • How to set text color in CRichEditCtrl?
    D David YueZuo

    Hi all, Who can help me for my below question? I will appriciate that. In my MFC project, I used RichEdit replacing RichEdit2, but the color of the text are shifted one unit. My code: CString strings[3] = {_T("Apple"), _T("Orange"), _T("Pear")}; for (int i = 0; i < 3; i ++) { CHARFORMAT2 cf; m_richEditCtrl.GetSelectionCharFormat(cf); if ( i % 2 == 0 ) { cf.crTextColor = (DWORD) RGB(255, 0 , 0); // Red color } else { cf.crTextColor = (DWORD) RGB(0, 0, 225); // Blue color } cf.dwEffects = static_cast(~CFE_AUTOCOLOR); cf.dwMask = CFM_COLOR; long length = m_richEditCtrl.GetTextLength(); m_richEditCtrl.SetSel(length, -1); m_richEditCtrl.ReplaceSel(strings[i]); long newLength = m_richEditCtrl.GetTextLength(); m_richEditCtrl.SetSel(length, newLength ); m_richEditCtrl.SetSelectionCharFormat(cf); } When I used RichEdit1 the program works perfect, but after I used RichEdit2 the color of text shows weird. Accordding to the code, "Apple" should show red color, "Orange" should show blue color, "Pear" should show red color again. However, the actual text color are: letters "Apple" are red, "O" is red too, "range pe" are blue , and "ar" are red. That doesn't make any sense....:confused: Is there anyone can help me on that? :) Thanks!

    David Zuo

    C / C++ / MFC question c++ help tutorial

  • In MFC, how can I find the actual signature of a function which is combined with a specific notification [modified]
    D David YueZuo

    Hey guys, Help! I have been using visual C++ for a while, but there is a issue always make me confused. The description of the issue: We use this Macro very often: ON_NOTIFY(wNotifyCode, id, memberFxn), but how do you know what is the actual signature of memberFxn. For instance, when we use ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText) At the same time, we will define a function called OnToolTipText, the signature of this function is: OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult) For the parameter pNMHDR, we know the actual data type maybe not NMHDR, sometime we convert it by using a specific data type rather than using it directly. The actual struct of NMHDR is: typedef struct tagNMHDR { HWND hwndFrom; UINT idFrom; UINT code; } NMHDR; For the notification TTN_NEEDTEXTW, we convert parameter pNMHDR by using TOOLTIPTEXTA, so my question is: how, when and where do you know you should use TOOLTIPTEXTA to convert it? why don't you use something else? is there any documents talk about what type we should use to convert a specific parameter? PS: If you don't mind, I have one more question, is there anyone knows how to use CListCtrl::SetInfoTip()? I want to set a tooltip for each cell of the table, I tired to use SetInfoTip(), but it doesn't work well. Can you teach me how to use it? Thank you so much!

    David Zuo

    C / C++ / MFC question c++ help tutorial

  • How to print message on console in mfc program?
    D David YueZuo

    Actually, I was a Java programmer. In Java, we can use both ways to display messages, no matter on console or GUI. Now, I am a C++ programmer, I m trying to use the same way to create a GUI-based MFC program. To create a console aside GUI for a actual user may not a good idea, but for the designer and programmer, it's a esaier and faster way to debug and monitor our program. In fact, I don't want to create any console, instead, I want to make the program able to run on console, and to recieve arguments from console. Also, program's messages would be displayed on current console during the running time. David Zuo

    C / C++ / MFC help tutorial c++ java question

  • How to print message on console in mfc program?
    D David YueZuo

    Now, I open a console by using "run" -> "cmd", type the directory of the file, then run my program on this console like: c:\cd temp c:\temp\app.exe -number 10 Again, app is a GUI-based MFC program, I added some printf statements in it, like printf("Hello world"); or std::cout << "hello world"; I hope the message "Hello world" could be displayed on my current console. Could you tell me how to do? Thanks! David Zuo

    C / C++ / MFC help tutorial c++ java question

  • How to print message on console in mfc program?
    D David YueZuo

    Thanks so much for your infor. Here, c:\app.exe -number 1 app.exe is just a MFC program (GUI-Based), I added some printf statements in it, like printf("Hello, world"), I hope this "Hello, world" can be displayed on my console. Actually, I used CEdit, CStatic and MessageBox as well, but only if I want the messages to be displayed on a dialog, editor. In Java, we can have: { ...... JOptionPane.showMessageDialog("Hello World"); System.out.print("Hello World"); ...... } then, message "Hello world" will be displayed on two different places, one is on a dialog, another is on the console. I want to use the same way to deal with messages in MFC. Could you tell me how to do? Thanks David Zuo

    C / C++ / MFC help tutorial c++ java question

  • How to print message on console in mfc program?
    D David YueZuo

    Hi, I have been thinking about the problem below for a week :((, Is there anyone can help me? I m working on a MFC program, and I want to make the program support console (Command Line). I don't know why I can't use cout or printf to print anything out. I thought It could display messages on console when I launch the program on console (windows xp), like: c:\app.exe -number 1 but nothing came out on consle actually. I know that I can create another console to recieve messages from cout and printf, but I don't want to create any console in my program, I just want print some message on original console. In Java, we can print message on console by using System.out.print(), so is there any way, function or class I can use to print messages on the console in MFC program? Could you show me a simple example? Thanks so much! David Zuo

    C / C++ / MFC help tutorial c++ java 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