CS410 – Visual Programming Solved Subjective Portion
Q1. How can I use the CopyTo method of Windows Forms controls collection?
Answer:CopyTo takes all controls in a form and copies them into an array. You must specify the array and the starting position.
Ref: Handouts / MSDN
Q2. GetParent function syntax, return value, and usage
Answer:GetParent returns the parent window handle of a given child window. It is used when you need the parent window reference of a child.
Q3. Difference between Pen and Brush
- Pen: Used to draw lines and curves; outlines charts or trends.
- Brush: Used to fill interiors of shapes; colors bars in bar charts or sections in pie charts.
Q4. How to draw in a window without WM_PAINT
Answer:
Use the device context directly (GetDC/GetDCEx) to draw immediately while processing input. Release the context after drawing. Useful for dragging or resizing objects.
Q5. How does Windows keep track of files?
Answer:
Each running program or module is assigned a handle. This helps Windows track all files and modules.
Q6. Can a class exist without a namespace? Which namespace does it belong to?
Answer:
Yes. It belongs to the global namespace (unnamed).
Q7. Two working spaces in GDI environment
Answer: Logical and Physical.
Q8. Types of macros
- Object-like macros (act like data objects)
- Function-like macros (act like functions)
Q9. GDI working spaces names
Answer: Logical and Physical.
Q10. Predefined GDI objects in Windows
Answer: Pens, Brushes, Fonts, Palettes.
Q11. Macros explanation with example
- Object-like: behaves like a variable
- Function-like: behaves like a function, e.g., maximum of two numbers
Q12. What is a process?
Answer:
A process is a set of related actions executed to achieve a specific result.
Q13. Modal loop
Answer:
A loop used by modal dialogs to process messages while taking control over the main application loop.
Q14. Windows programming control process
Answer: Edit Control and Static Control.
Q15. Pointer to Constant vs Constant Pointer
- Constant pointer to variable: Pointer cannot change; data it points to can.
- Pointer to constant: Pointer can change; data it points to cannot.
Q16. GetParent function syntax
Answer: Returns handle of parent window for a child window.
Q17. Types of assertions
- Preconditions – at start of function
- Postconditions – at end of function
- Invariants – conditions in a defined region of program
Q18. Characteristics of child windows
- Appears inside parent’s client area
- Usually controls (buttons, text boxes)
- Sends notifications to parent
- Has a unique ID
Q19. Client area
Answer: Part of window where output (text, graphics) is displayed.
Q20. WinMain function
Answer: Entry point for Windows GUI programs. Has parameters for instance, previous instance, command line, and window style.
Q21. Message queues
Answer: Applications process messages in the queue of their threads.
Q22. Paint function usage
Answer: Prepares window for painting, erases background, provides device context handle.
Q23. Desktop Window vs Application Window
- Desktop: Created by system, uses bitmap background, example wallpaper.
- Application: Created by programs, has title bar, menu, icon, example calculator.
Q24. _cdecl calling convention
Answer: Caller cleans up the stack after function call.
Q30. Difference between stdcall and cdecl
- stdcall: called function cleans stack.
- cdecl: caller cleans stack.
Q31. Erase window function
Answer: Determines area to erase and fills it. Handles background erasing messages.
Q32. Clipboard working
Answer: Allows data sharing between applications, e.g., copy from Notepad and paste into Word.
Q33. GetDC function
Answer: Retrieves device context for drawing; release it after use.
Q34. Infinite recursion
Answer: Recursion that never ends, causing stack overflow.
Q35. Stack
Answer: Memory area for local variables and function call order.
Q36. Extern storage class
Answer: Declares global variable visible across modules; cannot initialize here.
Q37. Logical coordinate system setup
Answer: Use logical brush (defined in code) and physical brush (created by device driver).
Q38. If WM_ERASEBKGND not processed
Answer: System uses default background brush to erase window.
Q39. Virtual-Key message
Answer: Device-independent code identifying key purpose, used in keyboard messages.
Q40. Superclassing vs Subclassing
- Superclassing: Create new class using existing class functionality (adds features).
- Subclassing: Override existing window procedure within same process.
Q41. Parent & Child process table entries
Answer: Kernel handle value is identical in both parent and child processes.