|
I am not sure if this is the exact topic to post here however I thought I'd give it a try.
I have been coding MFC for a few years.
The look and feel of the GUI's (that I create ! ( Dialog based app) seems ( to me ) to look very ordinary .
Sometimes when you demo stuff to customers , part of the deal is to create "Flash" like GUI's that actually have the same functionality of an engineering application ( normally coded using MFC, C++). Customers most often get "wowed" by the new , cool , look and feel instead of the usual gray dialog with buttons and edit boxes.
I am in search of something ( library / component(s)) that can still preserve the ease of coding in MFC/C++ but exposes a whole new world of creating stunning GUI ( rich in color and action ).
I would appreciate if someone could provide ideas for achieving this .
Engineering is the effort !
|
|
|
|
|
There are loads of nifty looking controls on a certain website full of code articles... Gradient coloured bubble buttons, all sorts.
I will warn you though - when you venture into Nifty, you usually take a huge detour through Hideous.
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
I m working on VC++2005 MFC,an my project on SDI,so i use view class.
actually i m working on audio-video splitter,
here this problem occur in video window where i play video file it is a animate control.
so when i shift application video cant repaint.
anyone can tell me how can repaint the views?
thnks
modified on Wednesday, February 13, 2008 4:02 AM
|
|
|
|
|
You can call CWnd::Invalidate() in your view class to repaint the view.
|
|
|
|
|
thanks dear
i call this but it is not working.
|
|
|
|
|
Hi,
I found an interesting problem with a simple task.
I was adding a context menu to a tree view embedded on a dialog and the dialog is embedded on the main window.
I was using GET_X_LPARAM and GET_Y_LPARAM from windowsx.h
The value returned from GET_X_LPARAM is incorrect (negative) within the WM_NOTIFY section but the GET_Y_LPARAM is ok.
Of course the problem is easily solved by using GetCursorPos but has
(1) Anyone else seen this?
(2) Anyone else can replicate this?
(3) Can someone tell me why this is the case?
Upon looking at the WM_NOTIFY docs is it correct that LPARAM is getting overridden with the
NMHDR structure? So it actually is behaving correctly and it's just by change that the y member is correct and happens not to be overridden?
Regards,
Flip
|
|
|
|
|
From the docs...
WM_NOTIFY
The WM_NOTIFY message is sent by a common control to its parent window when an event has occurred or the control requires some information.
WM_NOTIFY
idCtrl = (int) wParam;
pnmh = (LPNMHDR) lParam;
So, yes, LPARAM needs to be cast to a NMHDR *. You then look at pNMHDR->code to look at what kind of notify it is, and then look up the docs for that one.
If you're adding a right click handler to a tree view, then you want to handle the NM_RCLICK code. That *just* sends the NMHDR structure, which has no position information embedded in it.
In which case, GetCursorPos or GetMessagePos (GetMsgPos?) are your only ways to go.
Success,
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
Yup, I thought as much when I read the docs before I posted. Thanks Iain.
I am doing exactly that. I an handling NM_RCLICK and using GetCursorPos();
Prior to that I was adding a context menu to a static window using WM_RBUTTONDOWN with the afforementioned macros. I was just expecting (incorrectly) that would work for all context menus.
Evidently it is better to just use GetCursorPos.
Also if it helps anyone else I could not catch the message properly until I used this
int id = TrackPopupMenu(hh,TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD,pt.x,pt.y,<br />
0,h,NULL);
id returns the menu item resource id that was selected
Does anyone know of a way to catch the message without using the TPM_RETURNCMD ?
I know for a top level menu its
WM_COMMAND
and a switch on
LOWORD(wParam)
Regards,
|
|
|
|
|
It bugs me that that the NM_CLICK & NM_RCLICK notifications don't have a cursor position in an extended NMHDR too. It just feels clumsy to get it separately.
I would recommend GetMessagePos rather than GetCursorPos. I've been caught out in the past by a breakpoint before the getcursorpos, moving the mouse and getting the "wrong" value.
-----
As for trackpopupmenu, the window h would get a WM_COMMAND with a lParam of the menu item id of the selected menu unless you specify TPM_RETURNCMD. As that would have to mesh in with the main menu commands of my application I always use TPM_RETURNCMD anyway. Keeps local commands to local definitions. No worrys about my popup in one part of my app clashing with the numbers for another.
The TPM_NONOTIFY flags turns off messages (eg) WM_MENUSELECT from being sent, etc.
Another error you may have had. The NM_RCLICK gets sent to the dialog window - but did you use the dialog's or the treeview's window handle for the hWnd param of TrackPopupMenu? Maybe you were handling the WM_COMMAND message in the wrong window? You could check by using spy++ and monitoring all windows in your app for WM_COMMAND.
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
Good tip re GetMessagePos - I will use it from now on.
Your were exactly right with regards to NM_RCLICK. I was using the incorrect handle.
Now it works with or without using the notify message in TrackPopupMenu. - Thanks.
Previously I was using spy++ and seeing the WM_COMMAND message but obviously that was getting eaten by the treectrl as that did not have its own message pump.
On another track with things that bug me about the w32 API (apart from all of it ) is the following.
Editing labels on trees using TVN_ENDLABELEDIT the following is necessary
to get the line length
allocate a string based on line length
set the first byte to the line length
pass resulting string to get the entire line which overwrites
the string with the actual desired data
<br />
HWND e = TreeView_GetEditControl(h);<br />
int len = SendMessage(e,EM_LINELENGTH,NULL,NULL);<br />
TCHAR *s = new TCHAR[len];<br />
*((LPWORD)s) = len;<br />
SendMessage(e,EM_GETLINE,NULL,(LPARAM)s);<br />
I suppose GetWindowText could be used but what a crazy API.
Regards,
|
|
|
|
|
That's a crazy was because you're not reading the documentation for TVN_ENDLABELEDIT...
The lParam of a WM_NOTIFY message points to a NMHDR structure. But this can be embedded as the first member of a different structure.
Looking at TVN_ENDLABELEDIT, it sends a TV_DISPINFO structure, who's beginning part looks a LOT like a NMHDR structure.
To get the text:
void CBusEdit_Commands::OnDeviceEndLabelEdit(NMHDR* pNMHDR, LRESULT* pResult)
{
TV_DISPINFO *pTVDispInfo = (TV_DISPINFO*)pNMHDR;
*pResult = FALSE;
if (pTVDispInfo->item.pszText == NULL)
return;
if (SomeFunctionInMySoftware (pTVDispInfo->item.pszText))
*pResult = TRUE;
}
Good luck,
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
I have put a picture control box on a MFC dialog window. How can I get the coordinate of the picture control box?
|
|
|
|
|
Code something like this:
HWND hwndControl = ::GetDlgItem(GetSafeHwnd(), IDC_PICTUREBOX);
ASSERT(hwndControl);
CRect rec;
VERIFY(::GetWindowRect(hwndControl, &rec));
VERIFY(::MapWindowPoints(NULL, GetSafeHwnd(), reinterpret_cast<LPPOINT>(&rec), 2) != 0);
Steve
|
|
|
|
|
I'm trying to pass a pointer to struct between a C++ DLL and a C# app, both of which I'm writing. The code below compiles and runs, but the C++ pointer does not seem to be copied to C#. I've simplified the code for ease of reading. I think I need to use MarshalAs and have tried it out but either I can't get it to compile or doesn't work. Any help that can be offered is greatly appreciated. Thanks!
My C++ DLL has the following declarations:
struct record {
char name[32];
}
__declspec(dllexport) void get_name(record *record_to_get);
void get_name(record *record_to_get)
{
record_to_get = local_unmanaged_record;
}
Here is my C# code:
public class Win32
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct record
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string name;
};
[DllImport("my_cpp.dll")]
public static extern void get_name(ref record record_to_get);
}
In another class, I have:
Win32.record test_record = new Win32.record();
get_name(ref test_record);
Console.Writeline("record data = {0}", test_record.name); // Nothing is printed
|
|
|
|
|
I need to catch Windows PowerDown from a process and block it.
This is nicely implemented in MS Outlook 2002 or later (try to power down your computer when MS Outlook is running)
1. How can I catch a Windows PowerDown (or Hibernation) Event without using window (HWND) message queue
2. A way to block or deactivate the PowerDown
Any help will realy help, thank you
|
|
|
|
|
What's the problem with using a window? It need not be visible.
Steve
|
|
|
|
|
we can't use visible HWND window in our app, and invisible window don't behave well
|
|
|
|
|
Invisible window work just fine. Windows use the technique itself, for example COM uses invisible windows in some circumstances. Later versions of Windows also have message-only windows.
Steve
|
|
|
|
|
I tried the way using creating classic HWND window receiving WM_POWERBROADCAST and returning BROADCAST_QUERY_DENY. Problem is - if I create the window and let it invisible, it don't receive any WM_POWEBROADCAST message.
|
|
|
|
|
Hello. I'm trying to load beta versions of my app on a few computers and encountering something I haven't seen before. On most of the computers the app (an executable and 1 dll) loads fine but on 2 machines I get a message saying that the installation was incorrect and the application won't run. I've run depends.exe and received an intimidating list of dependencies. On a sort of educated guess I've also loaded mfc80.dll, msvcr80.dll and msvcrt.dll, but all to no avail. Also, I'm able to load a debug version of the app when the release mode fails, but that's not any kind of long-term solution. If anybody has any suggestions that would be greatly appreciated. Thank you.
|
|
|
|
|
You need to execute vcredist_x86.exe on the target machine. This will install the MFC and C-runtime libraries.
You can download it from here[^]. If you have installed the SP1, check the links at the bottom of the page for the SP1 version.
|
|
|
|
|
I didn't want to reply until I tested it on a client's machine, but it worked perfectly. Thanks a lot!
|
|
|
|
|
How come I can work with int *, but it does not work the same for
Object ptr's
This code works, but just try changing the int to a class object
and NOTHING will work. Note: Object test code is not listed cause it dont work!
I'm trying to learn to work with class pointers, but I can't get anything to work
Thanks - Areal
********************************************* the code
// A simple class for testing pointers
class Object {
int id;
public:
Object() {};
~Object() {};
void setid(int _id) { id = _id;}
int getid() { return this->;id; }
};
int * foo( int * addr);
Object * foo( Object * addr);
int main(int argc, char* argv[])
{
// These are the test subjects
Object o, obj1;
int a;
// end area
// General pointers for both test cases
Object *op;
int *p;
int *swap_addr;
Object *op_swap_addr;
// end area
// just initilize pointers
swap_addr=0;
p=0;
// end area
// Now set int/Object variables for testing
a = 10;
o.setid(999);
// end area
// Pointer assignment for int a
p=&a;
// end area
// Now run the test for the integer variable sending the pointer through foo
cout << "Value of a is ... " << a << endl;
cout << "Value of p is ... " << p << endl;
cout << "Value of *p is ... " <<*p << endl;
swap_addr = foo (p);
cout << "Value of swap_addr comming from foo is ... " << swap_addr << endl;
cout << "Value of *swap_addr comming from foo is ... " <<*swap_addr << endl;
// END FIRST AREA TEST PASSED
return 0;
}
int * foo( int * addr)
{
cout << "Value of addr in foo is ... " << addr << endl;
return addr;
}
// Object
Object * foo( Object * addr)
{
cout << "Value of addr in foo is ... "<< addr << endl;
return addr;
}
|
|
|
|
|
What's not working? Compiler errors? Runtime errors? Errors on what line(s)??
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Areal Person wrote: Object test code is not listed cause it dont work!
Perhaps is more useful if you post the not-working code, since you need to fix it.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|