|
Fiends,
I got a child dialog box. Problem is that on pressing the enter key the dialog disappears. What i want is that on pressing the enter key, some button on the dialog gets pressed. How can i do so.
Imtiaz
|
|
|
|
|
well you could set the focus on that button, when pressing enter that will activate it.
Other way is capturing the WM_KEYDOWN message in pretranslate func and check wParam for VK_RETURN.
Hope this helps you...
Regards,
Davy
|
|
|
|
|
Cwnd::SetFocus ();
if you use this into OnInitDialog (), you should switch its return value to FALSE .
TOXCCT >>> GEII power
|
|
|
|
|
HI,
How can i set timer Event to a dialog...
means how can i creat it, set it , kill it ,
any code
plz thanx
|
|
|
|
|
|
If is it mfc application , u can use this
BOOL CTelnetServerDlg::OnInitDialog()
{
… … …
… … …
… … …
SetTimer(100,20000,NULL);
… … …
… … …
… … …
}
BEGIN_MESSAGE_MAP(CTelnetServerDlg, CDialog)
//{{AFX_MSG_MAP(CTelnetServerDlg)
… … …
… … …
… … …
ON_WM_TIMER()
ON_WM_DESTROY()
… … …
… … …
… … …
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CTelnetServerDlg::OnTimer(UINT nIDEvent)
{
if (nIDEvent == 100)
{
// TODO: Add your message handler code here and/or call default
}
CDialog::OnTimer(nIDEvent);
}
void CTelnetServerDlg::OnDestroy()
{
KillTimer(100);
CDialog::OnDestroy();
}
|
|
|
|
|
Hey,
I have a couple of combo boxes, and When they hit new in the menu, I want it to clear, but when I use the m_varible.clear() command, it only clears the one I have highlighted or the last one I selected.
How do I get it to clear all of them?
Here is the code:
<br />
void CDEPDlg::OnFileNew() <br />
{<br />
m_type1.Clear();<br />
m_type2.Clear();<br />
m_type3.Clear();<br />
m_type4.Clear();<br />
m_type5.Clear();<br />
}<br />
<br />
Thanks for any help
|
|
|
|
|
Try this
extern CComboBox* pmyComboBox;
for (int i=0;i < pmyComboBox->GetCount();i++)
{
pmyComboBox->DeleteString( i );
}
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|
Hi,
try this
<br />
MyCombo.ResetContent(); <br />
<br />
SendMessage(MyComboHwnd, CB_RESETCONTENT, 0, 0);<br />
HTH
Frank
|
|
|
|
|
Thanks guys that worked.
How about an editbox, that is ready only, and it displays the text of a combo box, I tried the clear() function there too, but it doesn't work.
Any ideas?
Thanks
|
|
|
|
|
Hi,
<br />
MyEdit.SetSet(0, -1);<br />
MyEdit.Clear();<br />
<br />
SendMessage(MyEditHwnd, EM_SETSEL, 0, -1);<br />
SendMessage(MyEditHwnd, WM_CLEAR, 0, 0);<br />
HTH
Frank
|
|
|
|
|
use this code...
void CDEPDlg::OnFileNew()
{
// TODO: Add your command handler code here
m_type1.ResetContent();
m_type2.ResetContent();
m_type3.ResetContent();
m_type4.ResetContent();
m_type5.ResetContent();
}
enought to clear all ur combo contents okay;)
Hava nice day
with regards
loveablevirus
|
|
|
|
|
I have two dialog boxes dialog1, dialog2. One is the login.
how to pass the user and password from dialog1 to dialog2?
Visiual C++
Any hellp will be greatly appreciated
|
|
|
|
|
If you are using MFC.
You could store your password or other data to your CWinApp
And you could just call
((CYourApp*)AfxGetApp())->m_strPass ;
Or you could consider bad coding design but easier(my opinion)
global variable through
extern LPCTSTR g_YourPassword;
There are plenty of ways to do it. However, when you are storing sensitive data, you need to be more precautious in your design like consider encryption and etc.
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|
Basically what I want to do is drop a DLL from an executable. How exactly would I go about doing this. I was thinking about having the DLL as part of a resource file. I have no idea on how to do this. If anybody has source code, please post it.
|
|
|
|
|
|
|
Delete your *.sln file. (only do this if you do not depend on it to load your multiple projects)
rename your file *.vcproj manually in window explorer.
Then, open your renamed *.vcproj in VS IDE.
In your solution explorer, right click on your proj node and select rename.
(I guess this is not simple enough though)
There is another way to do it as well. If your project name is unique throughout your files. Use Find and Replace - Find In Files in your IDE to replace all the name in all your files. But this way is a bit risky.
(I hope there are easier ways to do it)
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|
Hi guys,
is there any article or tutorial shown that how to detect parallel port address of computer automatically?
no i just make simple stuff to work with the parallel port but to make the stuff work on other computers i want to make it can detect the port address automatically instead of key in the address.
Thank U for ur help in advance!!
|
|
|
|
|
#include <windows.h>
#define TEST_WINDOWS_NT (!(GetVersion() & 0x80000000))
/*********************************************************************
******************/
int GetParallelControllerKey(char *parKey)
{
HKEY hKey;
char myData[255];
LONG res;
DWORD mySize;
FILETIME ftLastWriteTime;
if (NULL==parKey)
return(-1);
*parKey=0;
char myKey[255];
sprintf(myKey,";HARDWARE\\DESCRIPTION\\System";);
res = RegOpenKeyEx(HKEY_LOCAL_MACHINE,myKey, 0, KEY_READ, &hKey);
if (res!=ERROR_SUCCESS)
return(-1);
DWORD dwIndex1;
char myKey1[255];
for (dwIndex1=0;dwIndex1<=10;dwIndex1++)
{
mySize=sizeof(myData);
res =
RegEnumKeyEx(hKey,dwIndex1,myData,&;mySize,NULL,NULL,NULL,&ftLastWriteT
ime);
if (res==ERROR_SUCCESS) // ERROR_SUCCESS 1
{
strcpy(myKey1,myKey);
strcat(myKey1,"\\");
strcat(myKey1,myData);
HKEY hKey1;
res = RegOpenKeyEx(HKEY_LOCAL_MACHINE,myKey1, 0, KEY_READ,
&hKey1);
if (res!=ERROR_SUCCESS)
return(-1);
DWORD dwIndex2;
char myKey2[255];
for (dwIndex2=0;dwIndex2<=10;dwIndex2++)
{
mySize=sizeof(myData);
res =
RegEnumKeyEx(hKey1,dwIndex2,myData,&mySize,NULL,NULL,NULL,&;ftLastWrite
Time);
if (res==ERROR_SUCCESS) // ERROR_SUCCESS 2
{
strcpy(myKey2,myKey1);
strcat(myKey2,";\\";);
strcat(myKey2,myData);
HKEY hKey2;
res =
RegOpenKeyEx(HKEY_LOCAL_MACHINE,myKey2, 0, KEY_READ, &;hKey2);
if (res!=ERROR_SUCCESS)
return(-1);
DWORD dwIndex3;
for (dwIndex3=0;dwIndex3<=10;dwIndex3++)
{
mySize=sizeof(myData);
res =
RegEnumKeyEx(hKey2,dwIndex3,myData,&;mySize,NULL,NULL,NULL,&;ftLastWrite
Time);
if (res==ERROR_SUCCESS) //
ERROR_SUCCESS 3
{
if
(0==strcmp(myData,";ParallelController";) )
{
strcpy(parKey,myKey2);
strcat(parKey,";\\";);
strcat(parKey,myData);
return(0);
}
} // ERROR_SUCCESS 3
} // for (dwIndex3
} // // ERROR_SUCCESS 2
} // for (dwIndex2
} // ERROR_SUCCESS 1
} // for (dwIndex1
return(-1);
} //GetParallelControllerKey
/*********************************************************************
******************/
int GetAddressLptPortInTheRegistry(int myPort)
{
HKEY phkResult;
char myKey[255];
char myData[255];
LONG res;
DWORD mySize;
DWORD myType;
res=GetParallelControllerKey(myKey);
if (res < 0)
return(-1);
sprintf(myData,";%s\\%d";,myKey,myPort-1);
res = RegOpenKeyEx(HKEY_LOCAL_MACHINE,myData, 0, KEY_READ,
&;phkResult);
if (res != ERROR_SUCCESS)
return(-1);
mySize=sizeof(myData);
myType=REG_BINARY;
res=RegQueryValueEx(
phkResult, // handle to key to query
";Configuration Data";, // address of name of value to query
NULL, // reserved
&;myType, // address of buffer for value type
(unsigned char *)myData, // address of data buffer
&;mySize // address of data buffer size
);
if (res != ERROR_SUCCESS)
return(-1);
//printf(";config data port %d 0x14 = 0x%02X 0x15 =
0x%02X\n";,myPort,myData[0x14],myData[0x15]);
return(myData[0x14] | myData[0x15]<<8 );
}
typedef BOOL (CALLBACK * PROCTYPE_Toolhelp32ReadProcessMemory)( DWORD
, LPCVOID, LPVOID, DWORD ,LPDWORD);
/*********************************************************************
******************/
int GetAddressLptPortInTheMemory(int myPort)
{
HINSTANCE hDLL=NULL; // Handle to DLL
PROCTYPE_Toolhelp32ReadProcessMemory myProcPointer=NULL;
hDLL = LoadLibrary(";kernel32";);
if (hDLL==NULL)
return(-1);
myProcPointer=(PROCTYPE_Toolhelp32ReadProcessMemory)GetProcAddress(hDL
L,";Toolhelp32ReadProcessMemory";);
if (myProcPointer==NULL) /*handle the error*/
{
FreeLibrary(hDLL);
return -1;
}
int portAddresses[]={0,0,0,0,0};
BOOL rtn=0;
DWORD cbLen=0;
//rtn = Toolhelp32ReadProcessMemory
rtn = myProcPointer
(0,
(LPCVOID *) 0x408,
portAddresses,
8,
NULL) ;
FreeLibrary(hDLL);
if (rtn==0)
return(-1);
if (portAddresses[myPort-1]<=0)
return(-1);
if (portAddresses[myPort-1]>=0x1000)
return(-1);
return(portAddresses[myPort-1]);
}
/*********************************************************************
******************/
int GetAddressLptPort(int myPort)
{
if(myPort<1)
return(-1);
if(myPort>3)
return(-1);
if (TEST_WINDOWS_NT)
return(GetAddressLptPortInTheRegistry(myPort));
return(GetAddressLptPortInTheMemory(myPort));
}
I found this in
http://www.lvr.com/jansfaq.htm
<B>Sonork 100.41263:Anthony_Yio
Life is about experiencing ... </B>
|
|
|
|
|
Hi, Anthony, thank you for reply. i m trying to use the one u suggest. but the code is hard to understand.
in case, i really dun know how the parameter "myPort" which in etAddressLptPort GetAddressLptPortInTheRegistry GetAddressLptPortInTheMemory
hv been used.
u have any idear abt it.
btw i m trying to get that book to c how. thank u very much!
|
|
|
|
|
I have a question for any of the experts out there but first here is some code...
I wrote the following code in C# for reading absolutely any file type. It does work perfectly for any file type and the method or style is called a binary file reader....
byte[] buffer = new Byte[SizeBuff];
int bytesRead = 0;
int ByteCounter = 0;
inputStream = File.OpenRead(@InputFile.Text);
while ((bytesRead = inputStream.Read(buffer,0,SizeBuff)) > 0)
{
ByteCounter = ByteCounter + bytesRead;
}
int TotalBytes = ByteCounter;
byte[] ModifyThisFIle = new Byte[TotalBytes];
int KiloByteCounter = 0;
inputStream.Close();
inputStream = File.OpenRead(@InputFile.Text);
while ((bytesRead = inputStream.Read(buffer,0,SizeBuff)) > 0)
{
for (int a = 0; a < bytesRead; a++)
{
ModifyThisFIle[a + (KiloByteCounter * 1024)] = buffer[a];
}
KiloByteCounter = KiloByteCounter + 1;
}
NOT TXT file types and NOT the simple ifstream statements....
What is the simular or identical method for reading each character of a file IN VC++??? "What is included within and including the while loop statements to read" in VC++ for binary files like JPG, HLP, PDF, etc???
Thanks,
demasoni.com
Elite
|
|
|
|
|
You could try the C api.
FILE *fSrc;
if ( (fSrc = fopen(".\\yourfile.bin", "rb")) == NULL)
assert(NULL);
int nLoop = yourGetFileSize(".\\yourfile.bin");
UCHAR *pBuffer = new UCHAR[nLoop +1];
int p = 0;
while (nLoop)
{
pBuffer[p] = (UCHAR)fgetc(fSrc);;
nLoop--;
p++;
}
fclose(fSrc);
delete [] pBuffer;
This will read byte by byte to the UCHAR buffer.
I am sure there are some STL based functions which could do the same.
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|
Thanks very much,
Interesting structure. I am not familiar with the term , "rb" that is located within the if loop but I assume with your above comment it means Reading Binary.
I also noticed something else that is a little bit different are the 2 semicolons ;; located within the while loop. That is new to me as well.
Please Quote me on this but I assume the pBuffer array is where each char is placed then it is deleted with the delete statement after you finnish what ever it is you need to do before you delete the array???
Also I noticed that you used UCHAR, I assume you could use BYTE as well???
Are there any special include files I need???
demasoni.com
Elite
|
|
|
|
|
I also noticed something else that is a little bit different are the 2 semicolons ;; located within the while loop. That is new to me as well.
that is typo.
Please Quote me on this but I assume the pBuffer array is where each char is placed then it is deleted with the delete statement after you finnish what ever it is you need to do before you delete the array???
yes
Also I noticed that you used UCHAR, I assume you could use BYTE as well???
Yes, UCHAR is a unsigned char which has the range of 0 to 255, thus equivalent to BYTE. Reason to use UCHAR is that data type name is self explanatory the reason of using the type, just to save a few comments on your code.
You can not use _int8 or char here because this data type are from –128 to 127.
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|