|
Hi,
Thank you for your reply.
Why is it that PreTranslateMessage() should not be used? All messages to the
window pass through this function. Isn't it the obvious place to trap the
working of a message? Or, is it reserved for system messages only?
I have tried the code with PreTranslateMessage() and it is not just working.
The code inside is just not getting called for the user-defined message. All
other messages are passing through the function as expected.
Am I missing out something?
With best regards,
Sayan
Email:sayanmukherjee@indiatimes.com
|
|
|
|
|
If you are creating a dialog class that is derived from CDialog, you can simply add a member variable in the CDialog derived class, set that member with your allocated data in the main dialog before you display your second dialog. Then you will be able to access that data in your OnDialogInit handler of your second dialog.
If you are simply calling CreateDialog or DialogBox to display your dialog, then call CreateDialogParam, or DialogBoxParam instead and set the dwInitParam to the allocated data pointer. In your OnInitDialog handler, the LPARAM of that message will be this pointer.
|
|
|
|
|
Can anybody let me know ow i can go about adding a simple volume control to my dialog window application. I am using VS 6.0.
Thanks
|
|
|
|
|
What exactly do u want ?
The UI element or how to control the
volume ?
|
|
|
|
|
Hello,
I was writing a Browser Shell today, for a learning project. And Navigating to the address was giving me all kindsa errors. First shell i created was a MDI, The method i used to nav to the new address didnt work completely, Then i tried it with a SDI, and it worked as long as you did somthing befor entering a new string to navigate too(like right clicking inside the app somehwere) Well after trying many methods i finally found the Answer to my problem.
But i still idndt understand why the first way i tried wasnt working. Heres what i was using,,
void CMainFrame::NewAddress()
{
CString strcAddress;
m_wndDlgBar.GetDlgItemText(IDC_EADDRESS, strcAddress);
((CHtmlView*)GetActiveView())->Navigate(strcAddress);
}
Why was this not working(crashing @ times, Other times working when clicking on somthing first)
Thanks
|
|
|
|
|
If you do not have an active view, then you will be accessing a NULL pointer in this line:
((CHtmlView*)GetActiveView())->Navigate(strcAddress);
If you change your code to this, you will not have a problem:
void CMainFrame::NewAddress()
{
CString strcAddress;
m_wndDlgBar.GetDlgItemText(IDC_EADDRESS, strcAddress);
CHtmlView* pHTMLView = (CHtmlView*)GetActiveView();
if (pHTMLView)
{
pHTMLView->Navigate(strcAddress);
}
}
|
|
|
|
|
Ahhhh i c...
Ya i changed the function to look like your example after researching some.
Thx you ..
|
|
|
|
|
hello, just like getting the mouse cursor coordinates to display a context menu, how can i get the flashing/blinking cursor (use to type text) from a screen (a CEditView )? Can anyone help?
56Kbps of sighs
|
|
|
|
|
I think what u mean is not the cursor but the 'Caret',
yes u can get the position but to get the exact location
about where it is located viz line, char pos has to be loacted
by you.
Use 'GetCaretPos' to get the pt(co-ords) and convert it into the
character position u need.
Just out of curiosity why do u need this position ?
|
|
|
|
|
Prem Kumar wrote:
I think what u mean is not the cursor but the 'Caret',
yes u can get the position but to get the exact location
about where it is located viz line, char pos has to be loacted
by you.
Use 'GetCaretPos' to get the pt(co-ords) and convert it into the
character position u need.
Just out of curiosity why do u need this position
First of all thanks you, i want to get this position to display a listbox because i wanna make something just like the visual studio intellisense
Thanks for all
56Kbps of sighs
|
|
|
|
|
Hi All,
I've got an app that eeds to copy some data to the clipboard. I wrote some code to do this based on a couple of articles I found here, and implemented a copy to clipoboard functionlaity for plain text. So far, so good. But, no I need to copy the same data out as RTF also. Anybody know a simple way I can copy data to the clipboard in multiple formats? Here's sopme code that's not quite working, I am getting a debug assertion the second time through the loop, for the second clipboard format (RTF(:
void CClipboardItem::CopyToClipboard(HWND& hWndNewOwner)
{
// Open the clipboard
OpenClipboard(hWndNewOwner);
EmptyClipboard();
// For every format in the set of supported formats, render data
FormatIterator it;
UINT uFormat;
for(it = m_setFormats.begin(); it != m_setFormats.end(); it++)
{
// Create a shared memory file
CSharedFile sf(GMEM_MOVEABLE | GMEM_SHARE | GMEM_ZEROINIT);
// Render the clipboard data to te shared memory file for the given format
uFormat = *it;
RenderClipboardData(sf, uFormat);
SetClipboardData(uFormat, sf.Detach()); // OOPS! This asserts the second time
}
// All done, let go of the clipboard
CloseClipboard();
}
Any idea why this doesn't work?
|
|
|
|
|
Hey, I'm trying to use Message Reflection for a button I've derived from CButton which is Owner Drawn. I put this in my Message Map:
ON_NOTIFY_REFLECT(WM_MOUSEMOVE,OnMouseMove)
but when I try to goto ClassView it gives me this error:
Parsing Error: Illegal line encountered.
Input Line: ON_NOTIFY_REFLECT(WM_MOUSEMOVE,OnMouseMove)
What am I doing wrong? I'm new to this relecting deal, is there an alternatve?
|
|
|
|
|
Hey, I'm trying to use Message Reflection for a button I've derived from CButton which is Owner Drawn. I put this in my Message Map:
ON_NOTIFY_REFLECT(WM_MOUSEMOVE,OnMouseMove)
but when I try to goto ClassView it gives me this error:
Parsing Error: Illegal line encountered.
Input Line: ON_NOTIFY_REFLECT(WM_MOUSEMOVE,OnMouseMove)
What am I doing wrong? I'm new to this relecting deal, is there an alternatve?
|
|
|
|
|
ON_NOTIFY_REFLECT() only works for WM_NOTIFY messages.
If you've derived a class you don't need to use reflection anyway; just add ON_WM_MOUSEMOVE() and implement OnMouseMove() & you're good to go!
Sometimes i only remember, The days when i was young Nowadays no one remembers when they were young and stupid... ADEMA, The Way You Like It
|
|
|
|
|
Well I tried that but I put a break in the OnMouseMove function and it never gets there there?
|
|
|
|
|
Make sure:- the button is being created/subclassed correctly: do other message handlers in your CButton-derived class get called?
OnMouseMove() has the correct signature: void OnMouseMove(UINT nFlags, CPoint point); - you're moving the mouse over the button
Sometimes i only remember, The days when i was young Nowadays no one remembers when they were young and stupid... ADEMA, The Way You Like It
|
|
|
|
|
- Yes, DrawItem and OnCreate both get called (DrawItem repeatedly of course)
- No, OnMouseMove and OnTimer both do not work
- OnMouseMove does have that signature
- Of Course
I was led to believe that if the button was owner drawn it had to be reflected
|
|
|
|
|
Actually, when I turn OwnerDraw off the notifications get through just fine, so I think reflection is necessary...can you lead me through it? thanks in advance
|
|
|
|
|
Reflection is used by MFC to allow handling messages sent from a control to be handled by the control itself. WM_DRAWITEM is sent by the button control to its parent; however it is cleaner for the code to exist within a class derived from CButton, rather than wherever the CButton-derived class is used. So there is ON_WM_DRAWITEM_REFLECT() which causes DrawItem() to be called.
WM_MOUSEMOVE (OnMouseMove() ) and WM_TIMER (OnTimer() ) both are sent to the control itself, so they do not need reflection to be handled by the CButton-derived class.
None of this helps with your immediate problem, however
There's nothing special about an Owner-drawn button that keeps it from getting WM_MOUSEMOVE. Double-check (wait, i guess it'd be triple-check) that your class looks something like this:
BEGIN_MESSAGE_MAP(CButtonDerivative, CButton)
ON_WM_DRAWITEM_REFLECT()
ON_WM_MOUSEMOVE()
END_MESSAGE_MAP()
void CButtonDerivative::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
}
void CButtonDerivative::OnMouseMove(UINT nFlags, CPoint point)
{
}
Sometimes i only remember, The days when i was young Nowadays no one remembers when they were young and stupid... ADEMA, The Way You Like It
|
|
|
|
|
I have a folder that i would like to password protect so you double click on it and you get a password box there needs to be one password that shows the folder and one that shows a different folder and anything else you put in stops you opening it?
How can this be done?
|
|
|
|
|
this sounds like a windows question more than a coding question? win NT lets you setup folder permissions if you are using NTFS, if your running win 9X then this isn't possible without a 3rd party peice of software
-dz
|
|
|
|
|
3rd party software like.....
|
|
|
|
|
Go search on download.com or some other site.. win9x uses fat16 or fat32 which has no security at all.. ntfs is the nt file system which lets you set read/write/edit/delete permissions for files or folders.. if you are on fat16 or fat32 then you have to get a piece of software which fakes this out.. but even this can easily be bypassed by just booting to dos and doing whatever you want with the files..
-dz
|
|
|
|
|
I'm a total virgin when it comes to shell extensions, but I think this is where they would come into play. Check under the Shell section. Mike Dunn has wrote some cool articles on Shell extensions which should get you well under way.
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I do not know, whether this can be helpfull, but according to msdn:
Multiple Data Streams
NTFS supports multiple data streams, in which the stream name identifies a new data attribute on the file. Each data stream is an alternate set of file attributes. Streams have separate opportunistic locks, file locks, allocation sizes, and file sizes, but files can be shared.
Maybe it is possible to define such stream as password-stream associated with given file system object
Mukkie
|
|
|
|