|
|
use _tSplitPath api,that may help you in above cause
and for removing '\' use CString::trimRight function
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
I display HTML reports in a CWebbrowser2 control embedded in my dialog based app. I also draw graphs within it using DHTML. They will only print if "Print Background Colours and Imgages" is set within Internet Options in the control panel. Is there a way I can set this for just the webbrowser control and not globally?
TIA
I feel like I'm diagonally parked in a parallel universe
Jerry Davis
http://www.astad.org http://www.jvf.co.uk
|
|
|
|
|
Hi all
I tried to use CursorClip to limit my drawing region on SDI. Any easier way to do that? I need to limit my drawing region to a rectangle (400x400 pixels).
Thanks;)
|
|
|
|
|
RECT rcClip; // new area for ClipCursor
RECT rcOldClip; // previous area for ClipCursor
// Record the area in which the cursor can move.
GetClipCursor(&rcOldClip);
// Get the dimensions of the application's window.
rcClip = your_rectangle(400x400);
// Confine the cursor to the application's window.
ClipCursor(&rcClip);
//
// Process input from the confined cursor.
//
// Restore the cursor to its previous area.
ClipCursor(&rcOldClip);
|
|
|
|
|
THanks for the code. But I am still quite confused.
rcClip = your_rectangle(400x400);
When I use GetClientRect(), it retrieved the coordinates of the top left of the client. However, when I am using SDI, there is menu and toolbar.
Can you write more detailed? I am new to visual C++ but I have programming experience.
Thanks;)
|
|
|
|
|
POINT p;
GetClientRect(hwnd, &rcClip);
p.x = rcClip.left;
p.y = rcClip.top;
ClientToScreen(hwnd, &p);
OffsetRect(&rcClip, p.x, p.y);
ClipCursor(&rcClip);
ShowCursor(TRUE);
//////////////////////////////
// The GetClientRect function retrieves the coordinates of a window's client area. The client coordinates specify the upper-left and lower-right corners of the client area. Because client coordinates are relative to the upper-left corner of a window's client area, the coordinates of the upper-left corner will be (0,0).
// The ClientToScreen function replaces the client coordinates in the POINT structure with the screen coordinates. The screen coordinates are relative to the upper-left corner of the screen.
// The OffsetRect function moves the specified rectangle by the specified offsets.
// The ClipCursor function confines the cursor to a rectangular area on the screen. If a subsequent cursor position (set by the SetCursorPos function or the mouse) lies outside the rectangle, Windows automatically adjusts the position to keep the cursor inside the rectangular area.
|
|
|
|
|
Hi!
I am looking for a control, where i can select the text width. For example in MS Excel if i want to import a textfile with a fixed width.
http://schueler.bulme.at/~vodep_mi/screen.png
(Sorry i only have office on mac)
Does anybody know how i can build such a control with the MFCs?
thx,
regards mike
|
|
|
|
|
I got a button, so i want0 when user moves the arrow on the button it shows a help hint. In the properties i found the menu HelpID, and i can do it true or false - what is it, and how can it help?
|
|
|
|
|
You can use CToolTipCtrl for creating hits. Have a look @ msdn for CToolTipCtrl.
|
|
|
|
|
So i tried to make a CToolTipCtrl;
in the InitDialog()
a call:
m_MyToolTip.Create(this,TTS_ALWAYSTIP);
m_MyToolTip.AddTool(GetDlgItem(IDC_BUTTON1),"Rassul");
But, nothing hapens, a tooltip doesnt appear when i move the cursor over the button.
|
|
|
|
|
Hello!
I ran into a problem, that can be simplified like this, consider the following code:
----8<--------8<--------8<--------8<--------8<----
#include <fstream>
using namespace std;
int main(int argc, char* argv[])
{
ofstream("myFile.txt") << "Hello" << endl;
return 0;
}
---->8-------->8-------->8-------->8-------->8----
I would expect this to put "Hello" in the file, but it prints the string address there.
I can't see why.
If you write:
ofstream("myFile.txt") << "Hello" << " men" << endl;
then " men" will be printed correctly, while "Hello" will be printed as the address.
Please note that this happens ONLY if you are using a temporary as the destination stream and ONLY with the leftmost object and ONLY if it's a string constant.
All the following versions behave as I would expect:
ofstream("myFile.txt") << (char*) "Hello" << endl;
//
ofstream("myFile.txt") << 123 << "Hello" << endl;
//
ofstream("myFile.txt") << 1.5f << endl;
//
ofstream myFile("myFile.txt");
myFile << "Hello" << endl;
//
I tried this with Visual Studio 2003 under WinXP and with the GNU compilare under Linux: same result, so it seems to be an intended behavior, because I tend not to think that I found any STL implementation issue. However, I found nothing in the STL documentation about this issue (hey... I found nothing, but maybe something is there hidden to my eyes ).
I am pretty much convinced that I forgot something very obvious and I'm being stupid, so if anyone can bring some light, it would be nice.
Thanks everyone.
Note: the original problem was found while creating a class deriving from basic_ostream to handle a custom error console, I also found several code sinppets around using temporary unnamed objects derived from basic_ostream but none of them was ever using a string constant as the leftmost object... -_-
C++U,
FrOYd
|
|
|
|
|
I am trying to create an ActiveX control (mediaplayer9.0 to be more specific) over document/view architecture. I have created the same application on VC++6.0. Its working fine.
But as soon as I port the same application from VC++6.0 to VC.Net and tries to run the application, it gives an error in call to GetParent() function as this function checks for ASSERT(::IsWindow(m_hWnd)). m_hWnd handle is assigned inside CreateControl() call, which is happening perfectly fine with VC++6.0.
I debugged the application in more detail for CreateControl() call in both VC++6.0 and VC.Net and found that in VC.Net:
1. COleControlSite::XOleIPSite::OnInPlaceActivateEx() function is getting called and assigning the (mediaplayer) control to be windowless.
In parallel to this VC++6.0 calls:
1. COleControlSite::XOleIPSite::OnInPlaceActivate(), which is doing nothing but returning "OK".
In addition to above inside CreateControl() VC.Net calls:
1. COleControlSite::AttachWindow(), which actually assigns the handle to “m_hWnd”. This is failing in VC.Net but working perfectly ok with VC++6.0 and that’s the reason why control is working fine with VC6.0 and not with VC.Net.
So my question is can anyone let me know why the behavior (which is leading to error) is changing in VC.Net.
FYI: .Net/VC7/atlmfc/src/mfc/occsite.cpp (This is the path for OnInPlaceActivateEx() and AttachWindow() functions).
Thanks,
Ajit
Amol Chavan
Persistent System Pvt. Ltd.
Member of Technical Staff
Bhageerath,402
Senapati Bapat Road,
Pune 411 016, India.
|
|
|
|
|
I wanna hook a certain window and coded as below but it didn't work!
please check my code.
In control dialog project..
BOOL (*install_hook)(HWND, HWND, DWORD);<br />
m_inst_hooker_dll = LoadLibrary("Hooker_dll.dll");<br />
if(m_inst_hooker_dll == NULL)<br />
{<br />
AfxMessageBox("Hooker_dll.dll was not found!");<br />
PostQuitMessage(0);<br />
return;<br />
}<br />
<br />
install_hook = (BOOL (*)(HWND, HWND, DWORD))GetProcAddress(m_inst_hooker_dll, "install_hook");<br />
<br />
DWORD process_di = 0;<br />
DWORD id = GetWindowThreadProcessId(edit, &process_di);<br />
<br />
if(!install_hook || !(*install_hook)(this->GetSafeHwnd(), edit, id))<br />
{<br />
AfxMessageBox("Fail to intall the Hooker,");<br />
PostQuitMessage(0);<br />
return;<br />
}<br />
'edit',found by FindWindow, the window handle of the external process which will be hooked, has a valide value. I verificated the value by sending a certail message.(It worked!)
In hook_dll project..
<br />
#include "stdafx.h"<br />
#pragma data_seg(".HKT")<br />
HINSTANCE g_module = NULL;<br />
HHOOK g_hook = NULL;<br />
HWND g_msg_destination = NULL;<br />
HWND g_hooked_window = NULL;<br />
#pragma data_seg()<br />
#pragma comment(linker, "/SECTION:.shared, RWS")<br />
<br />
BOOL APIENTRY DllMain( HANDLE hModule, <br />
DWORD ul_reason_for_call, <br />
LPVOID lpReserved<br />
)<br />
{<br />
switch (ul_reason_for_call)<br />
{<br />
case DLL_PROCESS_ATTACH:<br />
g_module = (HINSTANCE)hModule;<br />
break;<br />
<br />
case DLL_PROCESS_DETACH:<br />
UnhookWindowsHookEx(g_hook);<br />
break;<br />
}<br />
return TRUE;<br />
}<br />
<br />
LRESULT CALLBACK proc(int nCode, WPARAM w_param, LPARAM l_param)<br />
{<br />
if(nCode >= 0)<br />
{<br />
static char buf[256];<br />
int n;<br />
<br />
n = ::SendMessage(g_hooked_window, WM_GETTEXT, 256, (LPARAM)buf);<br />
buf[n] = 0;<br />
::SendMessage(g_msg_destination, WM_SETTEXT, 0, (LPARAM)buf);<br />
}<br />
<br />
return ::CallNextHookEx(g_hook, nCode, w_param, l_param);<br />
}<br />
<br />
extern "C" __declspec(dllexport)BOOL install_hook(HWND dest_window, HWND hooked_window, DWORD thread_id)<br />
{<br />
if(!hooked_window) return FALSE;<br />
g_msg_destination = dest_window;<br />
g_hooked_window = hooked_window;<br />
g_hook = ::SetWindowsHookEx(WH_GETMESSAGE, proc, (HINSTANCE)g_module, thread_id);<br />
return TRUE;<br />
}
It seems that my hook-procedure was not inserted to the hook chain. and If I set the thread_id = 0, as global hook, It works well.
Please answer me.
|
|
|
|
|
Code delete all child Values and keys of a particular key
DWORD dwReturn = SHDeleteKey(hKey,sKeyName);
if(dwReturn != ERROR_SUCCESS)
{
return FALSE;
}
else
{
HKEY hChildKey = NULL;
if(RegCreateKey(hKey,sKeyName,&hChildKey) == ERROR_SUCCESS)
{
return TRUE;
}
else
{
return FALSE;
}
}
|
|
|
|
|
Nope. SHDeleteKey will fail on NT where there are sub keys or values. See MSDN
this is how i do it
void
VPropertyRegistryPersister::DeleteRegKey(HKEY parentKey, LPCTSTR path)
{
DWORD index = 0;
DWORD nameBuffSize = MAX_PATH;
TCHAR nameBuff[MAX_PATH];
FILETIME lastWriteTime;
HKEY key = OpenKey(parentKey, path);
long result;
while((result = RegEnumKeyEx(key, index, nameBuff, &nameBuffSize,
NULL, NULL, NULL, &lastWriteTime)) != ERROR_NO_MORE_ITEMS)
{
RegistryException::VerifyAndThrow(result, "RegEnumKeyEx");
result = RegDeleteKey(key, nameBuff);
RegistryException::VerifyAndThrow(result, "RegDeleteKey");
index++;
nameBuffSize = MAX_PATH;
}
RegCloseKey(key);
RegDeleteKey(parentKey, path);
}
|
|
|
|
|
Josh Gray wrote:
Nope. SHDeleteKey will fail on NT where there are sub keys or values. See MSDN
funny it work perfectly on XP (haven't tried it on NT)
MSDN doesn't say anything about SHDeleteKey
all it says is
Deletes a subkey and all its descendants. The function will remove the key and all of the key's values from the registry.
Clickity[^]
|
|
|
|
|
wierd. In my installed version of MSDN at the very bottom it says
Windows 95: This function deletes a subkey and all its descendants.
Windows NT: The specified key must not contain any subkeys.
|
|
|
|
|
I actually had previously used it to do console applications on Visual C++ but never used MFC before. I had a problem; I was told to set a 10 by 10 area by using Matrix in MFC coding and use it to check whether the image has any little "black spots". If it does, I have to set these small little "black spots" of the image from "255" or anything else to zero. The codings must be in a function.
I did it but there were some problems with the codes. It does not work!!
Pls do kindly reply. I needed this asap. Thanks!
Below are the codes:
<br />
void CMediVisionView::MatrixImage()
{ <br />
int i, n, refer;<br />
<br />
if(no_of_rows==512 && no_of_cols==512){<br />
<br />
refer = 0;<br />
<br />
n = 0;<br />
for(i=0; i<512-5; i++)<br />
{<br />
if (image512[n]==0 && image512[n+1]==0 && image512[n+2]==0 && image512[n+3]==0 && image512[n+4]==0 && image512[n+5]==0 && image512[n+6]==0 && image512[n+7]==0 && image512[n+8]==0 && image512[n+9]==0){<br />
<br />
if(image512[n]==0 && image512[n+512]==0 && image512[n+(512*2)]==0 && image512[n+(512*3)]==0 && image512[n+(512*4)]==0 && image512[n+(512*5)]==0 && image512[n+(512*6)]==0 && image512[n+(512*7)]==0 && image512[n+(512*8)]==0 && image512[n+(512*9)]==0){<br />
<br />
if(image512[n+9]==0 && image512[n+512+9]==0 && image512[n+(512*2)+9]==0 && image512[n+(512*3)+9]==0 && image512[n+(512*5)+9]==0 && image512[n+(512*6)+9]==0 && image512[n+(512*7)+9]==0 && image512[n+(512*8)+9]==0 && image512[n+(512*9)+9]==0){<br />
<br />
if(image512[n+(512*9)]==0 && image512[n+(512*9)+1]==0 && image512[n+(512*9)+2]==0 && image512[n+(512*9)+3]==0 && image512[n+(512*9)+4]==0 && image512[n+(512*9)+5]==0 && image512[n+(512*9)+6]==0 && image512[n+(512*9)+7]==0 && image512[n+(512*9)+8]==0 && image512[n+(512*9)+9]==0){<br />
<br />
image512[(n+512)+1]=0;<br />
image512[(n+512)+2]=0;<br />
image512[(n+512)+3]=0;<br />
image512[(n+512)+4]=0;<br />
image512[(n+512)+5]=0;<br />
image512[(n+512)+6]=0;<br />
image512[(n+512)+7]=0;<br />
image512[(n+512)+8]=0;<br />
<br />
<br />
image512[n+(512*2)+1]=0;<br />
image512[n+(512*2)+2]=0;<br />
image512[n+(512*2)+3]=0;<br />
image512[n+(512*2)+4]=0;<br />
image512[n+(512*2)+5]=0;<br />
image512[n+(512*2)+6]=0;<br />
image512[n+(512*2)+7]=0;<br />
image512[n+(512*2)+8]=0;<br />
<br />
image512[n+(512*3)+1]=0;<br />
image512[n+(512*3)+2]=0;<br />
image512[n+(512*3)+3]=0;<br />
image512[n+(512*3)+4]=0;<br />
image512[n+(512*3)+5]=0;<br />
image512[n+(512*3)+6]=0;<br />
image512[n+(512*3)+7]=0;<br />
image512[n+(512*3)+8]=0;<br />
<br />
<br />
<br />
image512[n+(512*4)+1]=0;<br />
image512[n+(512*4)+2]=0;<br />
image512[n+(512*4)+3]=0;<br />
image512[n+(512*4)+4]=0;<br />
image512[n+(512*4)+5]=0;<br />
image512[n+(512*4)+6]=0;<br />
image512[n+(512*4)+7]=0;<br />
image512[n+(512*4)+8]=0;<br />
<br />
<br />
<br />
image512[n+(512*5)+1]=0;<br />
image512[n+(512*5)+2]=0;<br />
image512[n+(512*5)+3]=0;<br />
image512[n+(512*5)+4]=0;<br />
image512[n+(512*5)+5]=0;<br />
image512[n+(512*5)+6]=0; <br />
image512[n+(512*5)+7]=0;<br />
image512[n+(512*5)+8]=0;<br />
<br />
<br />
<br />
image512[n+(512*6)+1]=0;<br />
image512[n+(512*6)+2]=0;<br />
image512[n+(512*6)+3]=0;<br />
image512[n+(512*6)+4]=0;<br />
image512[n+(512*6)+5]=0;<br />
image512[n+(512*6)+6]=0;<br />
image512[n+(512*6)+7]=0;<br />
image512[n+(512*6)+8]=0;<br />
<br />
<br />
<br />
image512[n+(512*7)+1]=0;<br />
image512[n+(512*7)+2]=0;<br />
image512[n+(512*7)+3]=0;<br />
image512[n+(512*7)+4]=0;<br />
image512[n+(512*7)+5]=0;<br />
image512[n+(512*7)+6]=0;<br />
image512[n+(512*7)+7]=0;<br />
image512[n+(512*7)+8]=0;<br />
<br />
<br />
image512[n+(512*8)+1]=0;<br />
image512[n+(512*8)+2]=0;<br />
image512[n+(512*8)+3]=0;<br />
image512[n+(512*8)+4]=0;<br />
image512[n+(512*8)+5]=0;<br />
image512[n+(512*8)+6]=0;<br />
image512[n+(512*8)+7]=0;<br />
image512[n+(512*8)+8]=0;<br />
<br />
refer = 0;<br />
n++;<br />
refer++;<br />
}<br />
}<br />
}<br />
}<br />
}<br />
}<br />
<br />
}<br />
<br />
|
|
|
|
|
This is weird code, dude.
pohcb_sonic wrote:
n= (512-(Rectn_y+1))*512 + Rectn_x;
refer = 0;
n = 0;
Do you mean to set n twice ?
pohcb_sonic wrote:
n++;
refer++;
You can use the comma operator to make your loop look like this:
for(i=0; i<507; i++, n++, refer++)
pohcb_sonic wrote:
refer = 0;
n++;
refer++;
This means that refer will always equal 1, because you set it to 0, THEN increment it. Why ?
From what I can see, your loop sets all values to 0, but only if all values are already zero. Why ?
Is this a real image, or just a 2 dimensional array ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
gday all,
Can anyone help me out with the formatting withing a list box?? At the moment i am just using m_permList.AddString() to add items to the list box but even if i put a formatted string with \t etc between words it will only give one space between words?? Thanks
Steve
|
|
|
|
|
The list box must have been created with the LBS_USETABSTOPS style.
Try to use m_permList.SetTabStops(...).
Or see more on:
http://www.codeguru.com/Cpp/controls/controls/lists,treesandcombos/article.php/c2325/
|
|
|
|
|
I will create an ActiveX in our project, it is a telnet logon terminal, we want it just like a true terminal in webbrowser. it means some accelerator keys will be used, such as ctrl+e, ctrl+f. but these keys are captured by webbrowser whatever the focus in ActiveX or not, I want catch these keys, can it be realized? thanks.
|
|
|
|
|
I am a beginning programmer, so everything is still fairly fuzzy. Is there a means to pass a variable or variables to a fucntion called by a thread? Are the variables passed via the thread call or some more round about way????
David
|
|
|
|
|
ZeroGs wrote:
Is there a means to pass a variable or variables to a fucntion called by a thread?
There's always at least one thread per process, so a function is always called in the context of a thread. A function call is a function call, no matter where its called from.
A function has a signature, or prototype, that defines how it is to be called, the number and types of variables it expects, and the value, if any, it returns.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|