|
Thank you.
I want to run another dialog program. It has several edit controls. I want to fill the edit controls automatically, which requests send message to the edit control.
I tried several ways, but I couldn't the handle of the edit control.
The following is my code.
HWND h = ::GetDlgItem(hDlg, ID_EDIT_START); // hDlg is the handle of the dialog.
h return NULL.
Could you tell me what's wrong? How can I perform that?
Richard Woo
No pains, no gains.
|
|
|
|
|
Thank you.
I want to run another dialog program. It has several edit controls. I want to fill the edit controls automatically, which requests send message to the edit control.
I tried several ways, but I couldn't get the handle of the edit control.
The following is my code.
HWND h = ::GetDlgItem(hDlg, ID_EDIT_START); // hDlg is the handle of the dialog.
h return NULL.
Could you tell me what's wrong? How can I perform that?
Richard Woo
No pains, no gains.
|
|
|
|
|
Hello,
How you get the handle to dialog? did you use the GetWindow methode described in the firts posts?
To get the handle to another app(eg your another dialog app) you have to search for window´s caption and compare with your target window´s caption.
Once you have the window´s handle you can call GetDlgItem to retrieve a handle to dialog items.
I can send you two tests apps that explain it better.
|
|
|
|
|
I can get the handle of the dialog and the ID of the edit control.
But the edit control only has ID, not caption.
I do use GetWindow() to enumerate the desktop windows. It's a good way that can replace FindWindow function. My problem is I don't know how to use ID of the control to get the handle. I tried several functions, as GetDlgItem, GetDlgCtlID,...
Could you give me further information?
Thanks a lot.
Richard Woo
No pains, no gains.
|
|
|
|
|
Send me your two tests dialog apps.
|
|
|
|
|
I send you 2 apps.
Plx check.
Thanks a lot.
No pains, no gains.
|
|
|
|
|
you say its ok? I dont understand what do you want. whats is wrong so!?
|
|
|
|
|
I don't know why it works!
Just before I sent you the 2 apps, it showed "Not Found".
HWND g_FindSpecialControl(LPCSTR lpWndCap, int nIDDlgItem)
{
HWND hWnd;
int nID;
hWnd = FindWindow(NULL, lpWndCap);
if (hWnd == NULL) return NULL;
hWnd = GetWindow(hWnd, GW_CHILD);
while (hWnd != NULL)
{
hWnd = GetWindow(hWnd, GW_HWNDNEXT);
nID = GetDlgCtrlID(hWnd);
if (nID == nIDDlgItem) return hWnd;
}
return NULL;
}
It's strange!
No pains, no gains.
|
|
|
|
|
Its really very strange, I didn´t no changes but the path to test dialog.Now I think that there is nothing more to do!
|
|
|
|
|
Sorry about my troubling you.
I have to send my whole project to you.
Plx take some time to help me.
Thanks.
Richard Woo
No pains, no gains.
|
|
|
|
|
Ok. I will try.
|
|
|
|
|
Have you received my email with the 2 programs?
No pains, no gains.
|
|
|
|
|
|
Hi,
I tried another way and it did work!
I used EnumChildWindows function to enumerate all child windows of the dialog and I could get the handle of the edit control through a callback function.
Thanks for help.
Richard Woo
No pains, no gains.
|
|
|
|
|
Congratulations!
Glad to know you!
|
|
|
|
|
Hello everyone,
Can i add a control panel applet to the control panel through VB6 or VC++6 if yes how?
Thanks
|
|
|
|
|
Check Michael Dunn Control Panel project here.
|
|
|
|
|
in my application,i use memory detecting module.when i am debugging application,the output window display:
--> Detected memory leaks!
0 bytes in 0 Free Blocks.
45 bytes in 1 Normal Blocks.
0 bytes in 0 CRT Blocks.
0 bytes in 0 Ignore Blocks.
0 bytes in 0 Client Blocks.
Largest number used: 45 bytes.
Total allocations: 45 bytes.
--> Finished track memory leaks
Detected memory leaks!
The thread 0x44C has exited with code 0 (0x0).
Dumping objects ->
strcore.cpp(118) : {49} normal block at 0x00F41B70, 45 bytes long.
Data: < > 01 00 00 00 04 00 00 00 20 00 00 00 CB CE CC E5
Object dump complete.
who can help me about the strcore.cpp?;P
Mr.Whelk
-----------------------------
Zhuhai City ,Guangdong ,China
|
|
|
|
|
hehe. LaoXiang.
I think you can get good advice in CSDN.
<--MFC-->
|
|
|
|
|
Does anyone know how to close a modem connection? The connection was opened by the user, so I don't have a handle to it. But my app needs to hang up the modem when it terminates.
Afterthought:
I guess I need to query the state of the list of RAS connections and hang up the one that's active. Have to go find some RAS code at CP...
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I wrote a function that disconnects the modem:
#include <windows.h>
#include <ras.h>
void HangUp(){
RASCONN *rasc=malloc(1000);
DWORD bs,nc,i,j,dwRet;
RASCONNSTATUS rcs;
MSG msg;
TCHAR s[257];
rcs.dwSize=160;
rasc->dwSize=412;
dwRet=RasEnumConnections(rasc,&bs,&nc);
if(!bs)return;
rasc=realloc(rasc,bs);
if(RasEnumConnections(rasc,&bs,&nc))
return;
for(i=0;i<bs/412;i++){
HRASCONN hrc=rasc[i].hrasconn;
dwRet = RasGetConnectStatus(hrc, &rcs);
if (dwRet != ERROR_INVALID_HANDLE){
RasHangUp(hrc);
while (dwRet != ERROR_INVALID_HANDLE){
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
dwRet = RasGetConnectStatus(hrc, &rcs);
}
}
}
free(rasc);
}
Peter O.
|
|
|
|
|
Thanks very much, Peter!
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Sorry for msg below, i forgot to disable HTML.. Anyways, read on...
This function uses RC4's algorithm, but its not working properly. It works on small strings, but not large binarys. I cant find the bug in it.. Its tickin me off! Do you see anything wrong?
Usage;
strcpy(buffer, "This is my test string");
EncryptRC4(buffer, strlen(buffer), "secret", 6);
// buffer is then over-written with the new encrypted string.
// to un-encrypt, just call it again.
EncryptRC4(buffer, strlen(buffer), "secret", 6);
// buffer now holds orginal message.
// using strlen here isnt smart, because NULL character may be generated somewhere in the string buffer, but it fits the demo.
Function;
void EncryptRC4(char *sBuffer, int iBufferLen, char *sKey, int iKeyLen)
{
unsigned char sBox[256], k;
int iOffset, i = 0, j = 0;
for (i = 0; i < 256; i++)
sBox[i] = i;
for (i = 0; i < 256; i++) {
j = (j + sBox[i] + sKey[i % iKeyLen]) % 256;
k = sBox[i];
sBox[i] = sBox[j];
sBox[j] = k;
}
i = 0; j = 0;
for (iOffset = 0; iOffset < iBufferLen; iOffset++) {
i = (i + 1) % 256;
j = (j + sBox[i]) % 256;
k = sBox[i];
sBox[i] = sBox[j];
sBox[j] = k;
sBuffer[iOffset] = sBuffer[iOffset] ^ sBox[(sBox[i] + sBox[j]) % 256];
}
}
|
|
|
|
|
Ok, I'm an idiot! That function works perfectly! I just realized after 2 days of debugging, that the function is perfectly fine... it was that I was using the 'get' member function instead of the 'read' member function of the fstream class.... So i was reading the file in wrong... so it was encrypting the wrong data... LOL ... Blah! Basically the obove function works perfectly for anyone that would like to use it.
|
|
|
|
|
Ok, I simplified it down to just a function instead of a class. This function uses RC4's algorithm, but its not working properly. It works on small strings, but not large binarys. I cant find the bug in it.. Its tickin me off! Do you see anything wrong?
Usage;
strcpy(buffer, "This is my test string");
EncryptRC4(buffer, strlen(buffer), "secret", 6);
// buffer is then over-written with the new encrypted string.
// to un-encrypt, just call it again.
EncryptRC4(buffer, strlen(buffer), "secret", 6);
// buffer now holds orginal message.
// using strlen here isnt smart, because NULL character may be generated somewhere in the string buffer, but it fits the demo.
Function;
void EncryptRC4(char *sBuffer, int iBufferLen, char *sKey, int iKeyLen)
{
unsigned char sBox[256], k;
int iOffset, i = 0, j = 0;
for (i = 0; i < 256; i++)
sBox[i] = i;
for (i = 0; i < 256; i++) {
j = (j + sBox[i] + sKey[i % iKeyLen]) % 256;
k = sBox[i];
sBox[i] = sBox[j];
sBox[j] = k;
}
i = 0; j = 0;
for (iOffset = 0; iOffset < iBufferLen; iOffset++) {
i = (i + 1) % 256;
j = (j + sBox[i]) % 256;
k = sBox[i];
sBox[i] = sBox[j];
sBox[j] = k;
sBuffer[iOffset] = sBuffer[iOffset] ^ sBox[(sBox[i] + sBox[j]) % 256];
}
}
|
|
|
|
|