|
Aside: You may want to replace the AfxMessageBox() call with TRACE() , since the former causes a change in focus.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
This behaviour is caused by the default processing of the WM_NCLBUTTONDOWN message. When it processes this message, it enters a loop whereby it moves the dialog if the mouse moves, and exits the loop when it receives a WM_NCLBUTTONUP message. The fix is to not call the default processing for WM_NCLBUTTONDOWN . The problem then is that the user cannot move the dialog, so you'll have to implement the code for moving the dialog yourself.
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Your dialog should get a WM_MOVE message after the window has been moved (and WM_MOVING messages while
it's dragged).
Wouldn't that be enough ?
|
|
|
|
|
Hello !
I use the function CreateFile to open a COM port. Everything works fine unless the port number is only 1 digit (up to port 9). When I try top open the COM port10, the function returns INVALID_HANDLE_VALUE and a call to getLastError() gives me ERROR_FILE_NOT_FOUND (2).
Here is the code:
hCom = CreateFile(pszPortName,<br />
GENERIC_READ | GENERIC_WRITE,<br />
0, <br />
NULL, <br />
OPEN_EXISTING, <br />
0, <br />
NULL <br />
);<br />
What is the problem ??
|
|
|
|
|
For COM ports over COM9, you have to use the UNC notation, ie. COM10 = "\\.\COM10". This is only available for a NT-based OS, so it won't work on Win95/98/ME. Using this method, you can access up to COM255.
Remember if you're hardcoding the string it will need to be "\\\\.\\COM10" because of the character substitution.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
All,
I have tried a number of methods found here to get tool tips to work on my dialog button controls and have settled on using the method found in an article found here by Jean-Louis Guenego. All, including the method Jean-Louis employs, work great on Modal dialogs, but a soon as I try to use the exact same code in a Modaless dialog, the tool tips do not work. Jean-Louis Guenego's project also allows the placement of a bitmap on buttons and that part works fine on both modal and modaless dialogs.
I am using this code to create the dialog...
if (m_pSMDlg == NULL)
{
m_pSMDlg = new CFileDlg(TRUE,sDir,sExt,NULL);
if (m_pSMDlg->Create(MAKEINTRESOURCE(IDD_FILEDLG), NULL) == TRUE)
{
}
}
Is there something in the creation of my dialog I can do to allow tool tips to work?
Thanks,
Hal Roenick
|
|
|
|
|
If you read the message board below the article you referenced you would see that the same question was asked and answered there. http://www.codeproject.com/buttonctrl/tooltipressourcebutton.asp#xx653091xx[^]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
PJ,
I went and read what you suggested and had read that method many times before and it does not seem to work. The problem is that while I have the "ON_NOTIFY_EX(TTN_NEEDTEXT, 0, )
" in my message map, the "OnToolTipNotify" message is never sent by my buttons!
I have added all the code suggested for this method, but after doing so, I have placed a breakpoint withing the "OnToolTipNotify" message handler for my dialog and it never gets hit. The only thing I have been able to find that might be a clue is that because these buttons are set to "owner draw" (due to a bitmap being placed on them) there is a "notify" property that becomes disbled. I cannot figure out why my buttons do not send the "ON_NOTIFY" message when they are approached by the mouse.
Any thoughts?
Thank you,
Hal Roenick
|
|
|
|
|
I use that method all the time with no problems. Did you remember to add EnableToolTips(TRUE) in your InitDialog() function?
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
PJ,
Thanks for the reply. The difference might be that I am creating this dialog from within a .dll not a .exe. Do you know of anything that might change in that case?
Thanks again,
Hal Roenick
|
|
|
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_tool_tips.asp[^]
I never use dlls for dialogs, so I would not know if that makes a difference. My gut feeling says it doesn't.
Why not try to get it working without dlls first just to prove to yourself that the method works?
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
PJ,
I have. I found that I can get it to work in a .dll if the dialog is modal, but when it is created modaless the windows messages are no longer generated. I was able to create a modaless dialog in a .exe and the tool tips worked fine. It only seems to be a problem in a .dll with a modaless dialog.
Any other ideas would be appriciated.
Thanks again,
Hal
|
|
|
|
|
PJ,
If you use this method all the time, may I ask how you create your dialogs? The way I am doing it, for some reason neither OnToolTipNotify or reTranslateMessage are sent by any controls on my dialog.
Thanks,
Hal
|
|
|
|
|
Hello,
I want to create a DLL from SDK it is having one function that will export all other function structures. For the purpose of i will load DLL from dll wizard (dll wizard - created using mfc) means, displayed all the function name and parameters and parameter types, it also act as function calling at run time.
Example:
double add(double a, double b);
double sub(double a, double b);
double mul(double a, double b);
double div(double a, double b);
we write another one function,
GetInfo() - This function expose to all above funnciton structures, that structure act as function calling at runtime.
How do write GetInfo() function with in a dLL?
I would be thankful for any Idea, code sample ...
Regards
G. Inbhakumar.
|
|
|
|
|
look into __declspec(__dllimport) and __declspec(__dllexport) or alternately look into .def files - all of this is covered in depth in MSDN , either what you have locally or online - google is your friend
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
My Paint function is wrote as followed:
void OnPaint()
{
if (this == NULL)
return;
//Draw Signal using GDI
if(m_bUpdateSignal)
DrawSignals();
RECT rect;
GetClientRect(&rect);
int nWidth = rect.right - rect.left + 1;
//int nHeight = m_drawArea.Height();
int nHeight = rect.bottom - rect.top + 1;
CreateOffScreeenGraphics(nWidth, nHeight);
// draw from memory bitmap to window using GDI+
Graphics graph(GetSafeHwnd());
graph.DrawImage(m_pBitmapW, 0, 0);
}
When I run the program I found the program eated the memory quickly and occured most of CPU time. Is it a GDI+ Bug or I miss sometheing, I don't know why...
|
|
|
|
|
1) When handling the WM_PAINT message you should call BeginPaint() and EndPaint().
2) If you want to mix GDI and GDI+ you first create your Graphics object and use Graphics::GetHDC() to get the HDC used for GDI drawing. Do not forget to call Graphics::ReleaseHDC().
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Hi All,
We are using .lib files developed in vc++. Now we want to migrate those .lib files to dlls, so that dll functions can be called dynamically.
What are the steps involved to convert .lib to dll files? or are there any tools which can help?
akoleav
|
|
|
|
|
Create a dll project, add your lib source files to the project, and export the functions from the library that should be public. They can be exported using __declspec(dllexport) or via the .DEF file.
onwards and upwards...
|
|
|
|
|
But that allow me to call the dll functions dynamically? using Loadlibrary and then calling the function?
|
|
|
|
|
Yep.
onwards and upwards...
|
|
|
|
|
there's one caveat to this.
If you .lib was C++ then these names will be mangled, *especially* if they are classes, and calling them dynamically will be pretty difficult ( I have no idea how you tackle it). If the functions are just normal static functions, be sure to wrap them with extern "C" { } braces, that way the name mangling will be turned off as well.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
I want to write two simple c programs.
Important: There should be no client-server communication between them. They should communicate via a simple text file only.
The idea I want to implement is explained by the following example:
Assume that user "bob" in the domain "dom1" logged-on to the computer and executed PROGRAM A. Program A runs now under the security context of bob.
I want PROGRAM A to be able to take bob's access token, or bob's user sid, or bob's security context, and write it to a text file on the disk.
Now "bob" logs-off, and another user named "administrator" in the same domain ("dim1") logs-on to the same computer. "administrator" runs PROGRAM B. I want that PROGRAM B will retrieve the data of "bob" from the text file (that was created by program A), and use it to create a process that will run under the user context of "bob".
I.E. - I want PROGRAM B to be able to create a process that will run under the user context of "bob", without even knowing the password of "bob", but only his access token/user Sid/security context from a static file.
After searching the MSDN and some internet sites, I had an idea how to do that, but I am stuck now.
I will be grateful if anyone can help me to complete my idea or suggest other ideas...
My idea is described below:
Program A does:
1. Gets the user SID from the security token of itself (using OpenProcessToken
and GetTokenInformation with TokenUser)
2. It converts the User SID to a string format, using ConvertSidToStringSid,
and writes it to a file.
Program B does:
1. Read the file that was produced by the first program, and get the User SID
from it.
2. Convert the user SID from string to a valid binary user Sid, using
ConvertStringSidToSid.
The problem: I want Program B to use this user SID in order to create a process that will run under the user context that is represented by this user Sid.
The thing is that I don't know how to implement a creation of a process using user SID.
Does anyone have any idea?
Some notes:
1. It could be good if I had a way, in program B to create a "default" token and set its "User SID" field according to the user sid that was read from the file (and then use CreateProcessWithTokenW), but I didnt find a way to do that ("SetTokenInformation" enables set of other contents of a token, but not the user Sid).
2. There are functions to CreateProcessWithLogonW, CreateProcessWithTokenW,
CreateProcessAsUser, but I didnt find any function to create process with SID...
3. At first I thought about different implementation: that program A will take the whole access token of "bob" (and not only the sid) and write it to a text file. This way program B could read the token from the text file and use
CreateProcessWithTokenW...
But I didnt find a way to do that, because the token is a HANDLE, and I didnt find a way to write it in a text file in a way that it can be retrieved from it later and used by another program...
I will appreciate any kind of help,
Thanks a lot,
Maya.
|
|
|
|
|
I have a CListCtrl in my dialog. I want its size to be just fit enough to display the list elements, as in the control should resize itself based on the number of elements to be displayed(which is not known at compile time). It should not have a vertical scrollbar.
How can I do this?
Thanks
|
|
|
|
|
Hi
After populating your listbox with values, you can use CListCtrl::GetItemRect (with LVIR_BOUNDS code) to determine the size of the individual items in the list, calculate the total size, and resize the listctrl accordingly.
HTH
Martin
|
|
|
|