You are here:

C++/mfc and generally


thanks for answering quickly
2 questions
I wrote a little project graphics in 3d (a cube rotates and moving using tranformation in 3d)  .Because the view changes all the time it  causes flahing. Maybe there is another method to
make animation or even to avoid flashing

question n 2
If you want to "neutralize"  a part of the code  you should write //(comments) at the begining of each lines and if you have 100 lines or more....
Is there  a more rapidely or simple method because it takes times !  

Charly , Thank you for your question.

1. The flashing can be caused by erasing the window before it is repainted. See if you can suppress the erasing. If you are using MFC, look for OnPaint or OnDraw functions. If you call InvalidateRect or something similar, it has a flag to suppress the erasing.

If this doesn't fix the problem, try writing your image to an in-memory bitmap/device context pair, then copying the DC to the window's DC. This allows you to build up the correct image without displaying the new image until it is complete.

If this doesn't fix the problem, try using DirectDraw. I have never used it.

2. Use a macro I wrote to comment or uncomment any number of lines of code.

To use, select the lines of code then run the macro (I associate the macro with the Shift+/ keystroke).

Add the macro to your macros file, which on my computer is  C:\MSDEV\Common\MSDev98\Macros\Mymacros.dsm. Let me know if there are any undefined functions and I will send them to you.

Here is the macro:

Sub CommentSelectionToggle() ' Ctrl+Shift+/
'DESCRIPTION: Comment out or Uncomment entire selected lines of text
  Dim doc
  Dim sel

  Set doc = ActiveDocument

  ' Be sure active document is a text document
  If doc Is Nothing Then
     Exit Sub
  ElseIf doc.Type <> "Text" Then
     Exit Sub
  End If

  Set sel = doc.Selection

  ' ActiveDocument.Selection.StartOfLine ,dsExtend
  StartLine = sel.TopLine
  EndLine = sel.BottomLine
  sel.GoToLine EndLine
  ExecuteCommand "GoToIndentation"
  sel.EndOfLine dsExtend
  Text = sel.Text
  UnComment = (Left(Text, 2) = "//")
  ToggleCom StartLine, EndLine, UnComment

  ' Select the text again
  sel.GoToLine StartLine
  For curline = StartLine To EndLine
     sel.EndOfLine dsExtend
     sel.CharRight dsExtend
End Sub

Sub ToggleCom(StartLine, EndLine, UnComment)
  Dim sel
  Set sel = ActiveDocument.Selection

  sel.GoToLine StartLine
  ExecuteCommand "GoToIndentation"
  firstcol = sel.CurrentColumn
  For curline = StartLine To EndLine
     sel.GoToLine curline
     ExecuteCommand "GoToIndentation"
     col = sel.CurrentColumn
     'MsgBox firstcol, vbInformation, "App"
     If col > firstcol then col = firstcol
     sel.MoveTo curline, col
     'If firstcol <> 1 Then sel.CharRight , firstcol - 1
     sel.EndOfLine dsExtend
     Text = sel.Text
     If UnComment Then
        If Left(Text, 2) = "//" Then sel.Text = Mid(Text, 3)
        sel.Text = "//" & Text
     End If
End Sub

David Spector


All Answers

Answers by Expert:

Ask Experts


David Spector


Highly knowledgeable in the C++ language, Visual C++ (MSVC), Windows API, documentation and other quality-assurance techniques, and debugging. Knowledgeable in MFC, COM, GUI design, and object-oriented design.


I have been a software engineer since 1965. I have been published. My specializations have been: biomedical programming, compiler implementation, and many kinds of Windows programming. I don't do Databases or other business-oriented stuff.

Windows?/DOS Developer's Journal, ACM SIGPLAN Notices, and Computer Science Press.

ICCP Systems Programming Certification
Master's degree equivalent in Computer Science

©2017 All rights reserved.

[an error occurred while processing this directive]