|
I am having trouble overiding the default tooltip text that displays the tick count in a slider control.
My code is below. Any suggestion is greatly appreciated.
void CGraphView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
static CString strMinutes;
CToolTipCtrl *pTool;
if ((CSliderCtrl*)pScrollBar == &m_Slide &&
(nSBCode == SB_THUMBPOSITION || nSBCode == SB_THUMBTRACK)
)
{
pTool = m_Slide.GetToolTips();
strMinutes = "Test";
pTool->UpdateTipText(strMinutes, this);
pTool->Update();
}
CFormView::OnHScroll(nSBCode, nPos, pScrollBar);
}
sharpanil@yahoo.com
|
|
|
|
|
Hello,
I am using MSVC6 and have some trouble using the #pragma pack(...).
I have a header file where a structure is implemented:
<br />
#pragma once<br />
#pragma pack(push,8)<br />
<br />
struct MyStruct {<br />
};<br />
<br />
#pragma pack(pop)<br />
This structure I am using in two different cpp files in two different projects. If I am applying the sizeof() Operator to this structure in both projects I get two different results. Why??? I think I am using the #pragma pack directive properly.
By the way, the settings in "C++" -> "Code Generation" -> "Struct memeber alignment" is set to 8 bytes.
So has anyone an idea how this can be fixed???
Thank you very much for help
Chris
|
|
|
|
|
Try commenting the #pragma pack statements out and rebuild everything and see what happens.
You really don't need to do this if you are setting it to 8 though because that is the default.
Actually, it is a bit of a misnomer too. The compiler will align data members to the size of their type when this is selected. This is really only important when transmitting data structures between computers. However, you want to use the default whenever possible especially when using P4 processors. They can slow down considerably if their data is not aligned correctly.
|
|
|
|
|
It may not be related to packing but to something else. For example, the following struct will show different sizes if one of the projects is compiled for Unicode and the other is compiled for MBCS:
struct TheStruct
{
TCHAR buffer[20];
};
Also, many structures in the windows headers are defined with more or less members, depending on settings related to your target platform.
I'd suggest looking for things like that. You may, for example load this structure in each of the projects and inspect the contents in the Memory window while debugging.
--
jlr
http://jlamas.blogspot.com/[^]
-- modified at 1:05 Wednesday 31st August, 2005
|
|
|
|
|
I'm having a problem whne I try and register a control that is missing a component. It returns an exception error. It there an exception catch for the GetProcAddress?
Here's my code:
<br />
HINSTANCE dllhandle = NULL;<br />
HRESULT (WINAPI *lpfDllRegisterServer)();<br />
LPSTR pszFileExt = NULL;<br />
HRESULT hr = S_OK;<br />
<br />
pszFileExt = strrchr(pszFile, '.');<br />
if(pszFileExt)<br />
{<br />
pszFileExt++;<br />
if(stricmp(pszFileExt, "DLL") == 0 || stricmp(pszFileExt, "OCX") == 0)<br />
{<br />
dllhandle = LoadLibrary(pszFile);<br />
if(dllhandle)<br />
{<br />
lpfDllRegisterServer = (HRESULT(WINAPI*)())GetProcAddress(dllhandle, "DllRegisterServer");<br />
if(lpfDllRegisterServer)<br />
{<br />
hr = lpfDllRegisterServer();<br />
if(hr != S_OK)<br />
{<br />
CString strMsg("The following component failed to register.\n");<br />
strMsg += pszFile;<br />
AfxMessageBox(strMsg, MB_ICONEXCLAMATION);<br />
FreeLibrary(dllhandle);<br />
return FALSE;<br />
}<br />
lpfDllRegisterServer = NULL;<br />
<br />
}<br />
FreeLibrary(dllhandle);<br />
dllhandle = NULL;<br />
}<br />
}<br />
else if(stricmp(pszFileExt, "EXE") == 0)<br />
{<br />
char szCmdLine[MAX_PATH+1];<br />
sprintf(szCmdLine, "%s /RegServer", pszFile);<br />
<br />
STARTUPINFO startUpInfo = { sizeof(STARTUPINFO),NULL,"",NULL,0,0,0,0,0,0,0,STARTF_USESHOWWINDOW,SW_HIDE,0,NULL,0,0,0}; <br />
PROCESS_INFORMATION ProcInfo;<br />
<br />
CreateProcess(NULL, szCmdLine, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, <br />
NULL,&startUpInfo, &ProcInfo);<br />
}<br />
}<br />
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Hi all,
I use SendInput() API function to simulate keyboard events, and it works good for sending one key at a time, however when I try to send ALT+CTRL+DEL keys I dont get anything, here is my code:
<br />
INPUT inKB[3];<br />
<br />
::ZeroMemory(inKB,3*sizeof(INPUT));<br />
inKB[0].type=INPUT_KEYBOARD;<br />
inKB[1].type=INPUT_KEYBOARD;<br />
inKB[2].type=INPUT_KEYBOARD;<br />
<br />
inKB[0].ki.wVk=VK_MENU;<br />
inKB[1].ki.wVk=VK_CONTROL;<br />
inKB[2].ki.wVk=VK_DELETE;<br />
<br />
SendInput(3,inKB,sizeof(INPUT));<br />
<br />
inKB[0].ki.dwFlags=KEYEVENTF_KEYUP;<br />
inKB[1].ki.dwFlags=KEYEVENTF_KEYUP;<br />
inKB[2].ki.dwFlags=KEYEVENTF_KEYUP;<br />
<br />
SendInput(3,inKB,sizeof(INPUT));
I also tried this method:
<br />
KeyDown(VK_CONTROL);<br />
KeyDown(VK_MENU);<br />
KeyDown(VK_DELETE);<br />
<br />
KeyUp(VK_CONTROL);<br />
KeyUp(VK_MENU);<br />
KeyUp(VK_DELETE);
Note that the above functions use SendInput too. I dont know where is the problem??
Also, I need to SendInput the Windows Key to pop-up the start menu, and I also want to SendInput the SystemMenu Key...................
I have headache from this, any feedback is welcome
|
|
|
|
|
Have you tried playing with the Scan Code parameter of the ki member of the INPUT struct ?
~RaGE();
|
|
|
|
|
Hi-
Thanx for ur reply, but what is the wScan variable for? I searched the net and found that in some codes its a VK code, while it is ignored in most codes and set to 0. Also it is not well commented in the MSDN.
wScan
Specifies a hardware scan code for the key. -MSDN
Another point is that if it is a VK code, then i can pass only two keycodes at a time, (one in wScan and the other in wVk member variable) but I need to pass 3 VK codes at once (CTRL+ALT+DEL)????????
I will be grateful if you could offer some code or a link at least.
Regards,
Mohammad
|
|
|
|
|
Try adding KEYEVENTF_EXTENDEDKEY for VK_MENU and VK_CONTROL. Maybe for VK_DELETE too:
static void SetKeyboardInput(INPUT& input, short key, DWORD dwFlags)
{
input.type = INPUT_KEYBOARD;
input.ki.dwExtraInfo = 0;
input.ki.time = 0;
input.ki.wScan = 0;
input.ki.wVk = key;
input.ki.dwFlags = dwFlags;
}
void SendCtrlAltDel()
{
INPUT inKB[3];
SetKeyboardInput(inKB[0], VK_CONTROL, KEYEVENTF_EXTENDEDKEY);
SetKeyboardInput(inKB[1], VK_MENU , KEYEVENTF_EXTENDEDKEY);
SetKeyboardInput(inKB[2], VK_DELETE , 0);
SendInput(3, inKB, sizeof(INPUT));
inKB[0].ki.dwFlags |= KEYEVENTF_KEYUP;
inKB[1].ki.dwFlags |= KEYEVENTF_KEYUP;
inKB[2].ki.dwFlags |= KEYEVENTF_KEYUP;
SendInput(3, inKB, sizeof(INPUT));
}
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Thanks friend,
but it really did not work, even with setting KEYEVENTF_EXTENDEDKEY for the del key. I am really confused and i spent lots of time on this...
Regards,
Mohammad
|
|
|
|
|
I've been investigating this a bit.
Conclusion (short version):
You can't simulate Ctrl+Alt+Del.
Conclusion (longer version):
You can't simulate it as a keyboard sequence.
The proper way to simulate a Ctrl+Alt+Del is posting a broadcast WM_HOTKEY message. However, for that to work, the calling thread must be part of the Winlogon desktop.
You could use SwitchDesktop, but that in turn requires your thread to not have any open window or hook set.
There's a trick to work-around this too, which is published in many places, and is based on the open source of VNC. Basically, it requires spawning a new thread, and since this thread won't have any window or hook, it would in theory be able to switch to the Winlogon desktop and post the WM_HOTKEY. Some window in this desktop would react to the WM_HOTKEY message and respond in the usual way.
However, before calling SwitchDesktop you need to use OpenDesktop to obtain the handle of the Winlogon desktop. Although I'm not sure if this used to work in previous versions, it definitely doesn't work in modern versions. I've tried with WinXP+SP2, and every call to OpenDesktop for "Winlogon", no matter which access rights you request, fails with "access denied". From what I've seen in many forums, it doesn't work for Windows 2000 either.
I've seen claims that this would still work if your process is running as "LocalSystem", but I'm not sure about that.
--
jlr
http://jlamas.blogspot.com/[^]
-- modified at 0:13 Wednesday 31st August, 2005
|
|
|
|
|
Hi!
I have an application where I used Chris Mounders Grid. There has never been any problem until the last windows uppgrade KB893803v2 for Windows 2003.
My application is compiled with Visual Studio .NET 2003 and all code is unmanaged C++ and I have a Resoure-Only DLL with all my application text and dialogs.
In one of my popup dialog I have a CGridCtrl. The text to the header is from my recourse file.
After KB893803v2 uppgade the header text don't show in release mode, but in debug mode it is visible. Even the data filled out in the grid is invisble in release mode, but if I make a Copy Text to my clippboard the information is visible.
Any idea how to solve this problem?
MSc Bertil Morefält
|
|
|
|
|
It is an add-in that embeds tabs into Visual Studio 6 IDE. Just like the tabs in Visual Studio .NET IDE, it provides you an easier way to switch windows in Visual Studio 6 IDE.
Please have a look at my website:
http://www.visual-studio-booster.com/[^]
Your comments and suggestions are appreciated. Thanks!
/*
An easier way to switch windows in visual studio 6 :
http://www.visual-studio-booster.com/
*/
|
|
|
|
|
why don't you post it as an article on CodeProject ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
That's a good idea, thanks!
/*
An easier way to switch windows in visual studio 6 :
http://www.visual-studio-booster.com/
*/
|
|
|
|
|
eh eh, i do my best for beest suggestions
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
oh, i've just realized that it's a shareWare...
can't we benefit the source code ?!
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
I'm sorry that I'm not going to make it open-sourced currently. I suppose that I may change my mind someday
An easier way to switch windows in visual studio 6 :
[Visual Studio Booster]
|
|
|
|
|
toxcct wrote:
oh, i've just realized that it's a shareWare...
Is somobody still writing obnoxious nagshareware these days?
|
|
|
|
|
Is it free like WndTabs[^]?
I have been using WndTabs for many years and it works great. Any reason to switch?
John
-- modified at 23:45 Tuesday 30th August, 2005
|
|
|
|
|
Good Day,
I'm Using Visual Studio .Net.I Am Currently Studying Visual C++.Net.I Have Created A Windows Search Form.I Have Connected The Form To The Database.The Form Has The Following Text Boxes: Surname Name Id No.I Want To Be Able To Type In The Surname And Click Find.It Must Then Search My Database And Return The Name And Id No.I Would Really Appreciate The Code To Do This.
I Appreciate Your Help And Time
In Every Failure There Is Success
|
|
|
|
|
It depends on what kinda database structure you are using really. If you are using ADO.NET it goes something like this:
OnFindButtonClicked()
{
CString str,cmd;
GetDlgItemText(SURNAME_EDITBOX, str);
cmd.Format("SELECT Name,Id FROM yourTable WHERE surname = %s",str);
// here hook to adapter,dataset, datarow, the whole shebang...
SetDlgItemText(ID_EDITBOX,datarow->Item[S"id"]->ToString());
SetDlgItemText(NAME_EDITBOX,datarow->Item[S"name"]->ToString());
}
Honestly, it is really kinda complicated and alot of code. Here's a very helpful tutorial on ado by Mr. Tom Archer at codeguru.com:
http://www.codeguru.com/Cpp/data/mfc_database/ado/article.php/c4287/
I think there's also a data-bind way that uses wizards, but you'll have to ask someone else for that.
|
|
|
|
|
Hi, I'm using vs.net 2003 and I understand that you can create various string tables that automatically switch depending on the default language set in the windows os control panel. I would like to change the default language within my c++ program though. What code do I write to manually switch the string tables? Thanks.
e.g. Say I am using a Japanese OS, and I want the user to be able to alternate between the English version and Japanese version within the program without going to control panel.
|
|
|
|
|
you have to load from the resource table the string table to which you want to switch. then, use CString::LoadString() to get the strings from the table and CWnd::SetWindowText() to change the caption of the controls...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|