Lib or example code to handle bitmap in MFC [closed] - visual-c++

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I have small test to handle bitmap in MFC (VC++ 2008).
I want to process left mouse click or right mouse click on a image to call any event.
(I dont want to calculate coordinates, I only want to handle image as a object and left click, right click on that object)
Anyone know the MFC lib or source code, please help me.
Thanks.

Use a picture control to display the image. The picture control is represented in MFC by CStatic. Since CStatic does not generate the mouse notifications that you want you need to customize it, using the MFC subclassing technique.
First you create a control member variable of type CStatic. Then to add the custom mouse handling that you want you create a class derived from CStatic and add message handlers for all the mouse messages that you are interested in, like WM_LBUTTONDOWN and WM_RBUTTONDOWN. Change your control member variable to be your CStatic-derived class instead of CStatic. Now you are intercepting the mouse messages that come in to the picture control. Write a little code in each message handler to notify the parent dialog/form, like...
#define UWM_LIMAGECLICK (WM_USER+10) // your custom message
GetParent()->PostMessage(UWM_IMAGECLICK, IDC_IMAGE, 0); // your picture control's ID
The parent window can receive and handle this message with
ON_MESSAGE(UWM_LIMAGECLICK, OnLImageClick) // in the message map
LRESULT CYourParentClass::OnLImageClick(WPARAM wParam, LPARAM lParam)
{
....the image was L clicked
return 0;
}

Related

How to hide OutputMessages window in SALOME ParaViS? Some ideas in question body

I want to hide Output Messages window in SALOME v.8.3.0. Now I try to get access to QWidget "OutputWindow" with inner SALOME console.
One way which I want to do it is to find a slot which connects with triggered() signal of Tools->Output Window main menu action.
But I don't know how to capture slot if I emit my signal. Also, I couldn't find the slot implementation in the source code of ParaViS module.
Maybe you know how to capture slot or how to find which QObjects are spawned in this slot?
Or you know the simple way to hide this annoying window?...

Android Studio: Can I use one java class for multiple layouts? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I'm a beginner in Android Studio and am trying to figure out how to edit different layouts(.xml files) with one java class(.java). I am trying to get the id of an ImageView on another layout, but the findViewById of the ImageView returned null. What do I need to do? Also, I have two layout files because I am using a popupWindow. So, I need to access the ImageView of the popupWindow.
Thanks!
It sounds like you are just using Activity's findViewById, which would search the activity's layout for your ImageView. You would need to call findViewById on your inflated popup view:
View popupView = getLayoutInflater().inflate(R.layout.popup, null);
//Get your image view from the inflated popup
ImageView image = (ImageView) popupView.findViewById(R.id.imageView);

WM_PAINT not send when using WS_EX_COMPOSITE

I'm working in a legacy application using MFC.
We have a mechanism to enable/disable controls depending on some business logic.
This mechanism is implemented in the CView-derived class. The way it works is all the views in the application derived from a common CView-derived class (CBaseView) and on the PreTranslateMessage all controls of the view are enabled/disabled.
This worked fine so far because all controls send at least WM_PAINT message when they need to be painted. So the system worked without the user having to move the mouse or anything. I recently added some drawing features and I had to use WS_EX_COMPOSITE to get ride of some flickering. With this flag activated my CView-derived class is not getting any called to PreTranslateMessage when creating the view....so the controls are not disabled until the user moves the mouse over the control.
I understand there is no way to send WM_PAINT using WS_EX_COMPOSITE but is there other message I can use to get the same behaviour???
Edited:
I am currently using the OnIdle approach but it has a big drawback, the windows doesn't become idle until after drawing all the controls...so when you enter the screen al controls are enabled and inmediately they are disabled...this makes a quite ugly effect!
More solutions???
Thanks in advance...
The logical place to enable/disable controls would be CView::OnUpdate, it is called by the framework after the view's document has been modified and from OnInitialUpdate(); you can also call this function if there is some change that would trigger re-evaluation of your business logic.
EDIT
After reading the question a bit more closely, what you could also do is to post a private message at the end of OnInitialUpdate and "catch" it in your PreTranslateMessage:
PostMessage(WM_APP, 0, 0);
Calling InvalidateRect followed by UpdateWindow against the window in question will mark the entire client area as dirty and force an immediate repaint. Remember that WM_PAINT is not really a message, in the queue in the usual sense, it is pushed out after all other messages have been processed for that window, which would include any invalidations of the area being drawn. No message is generated at all if there are no invalid segments of the active window display.

How can I calculate the client area of an MFC CDialog without displaying it?

How can I obtain the Window Rect of a CDialog which is based on a dialog template. The dialog is not and can not be visible
It might be tricky with CDialog, because if you dont show the CDialog, the window handle is not created and you cant call GetClientRect.
Might i suggest calling CreateDialogIndirect instead to create the dialog, then you can get the client rect. You dont need to show the dialog. I think as long as the window handle is created, the GetClientRect should work. I am not an expert though and its been many years since i have written MFC code.
Well...
In Windows API-land, you could load the resource yourself (FindResourceEx, LoadResource), understand the binary structure of the dialog template resource (some clues at http://blogs.msdn.com/oldnewthing/archive/2004/06/22/162360.aspx), convert the size of the dialog in the dialog template from dialog units to pixels (check out http://msdn.microsoft.com/en-us/library/ms645475(VS.85).aspx).
I'd be curious why you'd want to do this, though.

Keyboard friendly light weight UML modeling tool? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I'm looking for a free UML tool that runs on Windows and lets me create simple diagrams very fast, with as little mouse fiddling as possible.
I have no need for code generation or fancy stuff, just UML style boxes with arrows.
What I would like is something that for example lets me add a new class with a keyboard shortcut and lets me enter the name without having to double click the added class or something like that. Just a simple app that let you model efficiently without getting the urge to eat your desk...
What I don't want is to have to drag an item from a toolbox to the surface, double click the item, enter the name, grab the mouse again, click the ok button, rince and repeat.
For Eclipse there is TextUML that lets you create diagrams using a textual notation, but I want it for .Net development and I don't want to run Eclipse just for a tiny diagramming plugin.
I have tried quite a few of the open source tools out there, but most of them have quite an awful user experience.
So, is there a tool that fits the above description?
If you really just want boxes with arrows, use GraphViz. It allows you to enter textual descriptions and the current Windows version is now able to provide a graphical preview of the text file. You can choose different shape types and it will allow you produce diagrams even as fancy as the following one.
I have a full-blown UML tool (the superb Enterprise Architect) but I still use GraphViz daily for simple sketch diagrams.
For more traditional UML examples with GraphViz see this blog and the UMLGraph site.
digraph {
/* notes */
subgraph cluster_legend {
graph [color=lightyellow style=filled]
node[shape=plaintext]
edge[style=invisible arrowhead=none]
Mac[label="On Macintosh\nonly" color=blue fontcolor=blue]
Next[label="Next Version" color=grey fontcolor=grey]
Mac->Next
}
edge [color=black fontcolor=black]
node [weight=bold fontsize=14 color=black fontcolor=black]
/* docs */
node[ shape=box3d]
AppMakerv2[label="AppMaker V2\nDocument" color=blue fontcolor=blue]
AppMakerX[label="AppMakerX\nDocument"]
/* Code */
node [shape=folder]
PP[label="PowerPlant\nPPob Resources" color=blue fontcolor=blue]
Classic[label="Classic Mac\nResource fork:\nMENU, DLOG, DITL" color=blue fontcolor=blue]
XAML
WPFApp[label="WPF Application\nXAML resources\nC# Code and properties"]
REALBasic[label="REALbasic Application\nXML format\nwindows and code" color=grey fontcolor=grey]
Cocoa[label="Cocoa Application\nxib resources\nObjective-C Code" color=grey fontcolor=grey]
hand[label="Hand Editing in\nAppMaker v2 GUI" shape=plaintext fontcolor=blue]
/* processes */
node[shape=ellipse]
Importer[color=blue fontcolor=blue]
Exporter[color=blue fontcolor=blue]
Converter
WPFGen[label="WPF\nGenerator"]
CocoaGen[label="Cocoa\nGenerator" color=grey fontcolor=grey]
RBGen[label="REALbasic\nGenerator" color=grey fontcolor=grey]
/* Mac workflow */
edge[color=blue]
PP->Importer
Classic->Importer
hand->AppMakerv2
Importer->AppMakerv2
AppMakerv2->Exporter->AppMakerX
/* cross-platform workflow */
edge[color=black]
XAML->Converter->AppMakerX
AppMakerX->WPFGen->WPFApp
/* future workflow */
edge [color=grey fontcolor=grey]
AppMakerX->CocoaGen->Cocoa
AppMakerX->RBGen->REALBasic
}
alt text http://www.aussiedesignedsoftware.com/AppMakerX/files/amxworkflow.png
try trace2uml
http://trace2uml.tigris.org/
it is free, easy to use and light
I find JUDE very good, lightweight software for modeling in UML. It's cross-platform, has community edition, it's easy to use, supports standard UML and diagrams look very nice.
http://jude.change-vision.com/jude-web/index.html

Resources