|
Given that the client (COM server) is communicating with the web server via TCP/IP, one solution is winsock.
Kuphryn
|
|
|
|
|
The unix C++ prog i am porting to windows uses 'lrint' which is rounding to nearest integer. What do I use in VS instead?
Appreciate your help,
ns
|
|
|
|
|
double d = 123.45;<br />
int x = floor(d);<br />
int y = ceil(d);
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi All
i have an application that written, which uses ado...when a user installs this application
he/she then has to configure a ODBC datasource manually
does ne1 know how i can do this automatically when the program installs? or can ne1 point me in the right direction
which type of setup project would be best for this ?? im using visual studio 2003
i assume that i need to edit the code in the setup program is that correct ????
thanks
si
|
|
|
|
|
You'll need to use SQLConfigDataSource() for that.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I am writing an HTML syntax highlighter for my MFC MDI app and I wrote a ParseAllLines function and it works perfectly for coloring the entire document. But I was wondering how to go about parsing/coloring as the user types into the rich edit control or pastes something into the document. Can anyone generally tell me what I need to do? Do I overwrite OnChange for the rich edit control? If so, what lines do I parse?
I appreciate any advice, thank you!
|
|
|
|
|
Handling EN_CHANGE message will tell you when text has changed, but I don't know how to get only the text that has changed. You might have to reparse the whole thing.
|
|
|
|
|
Hi, i want to paint inside a control;
Why? Because i want to change the color of the border of a group box
Does anyone know how to get the CRect with the dimensions of the border? Then i think i can attach a CBrush to that.
<br />
CWnd* pWnd = GetDlgItem(IDNAME);<br />
CDC* pControlDC = pWnd->GetDC();<br />
<br />
pWnd->Invalidate();<br />
pWnd->UpdateWindow();<br />
<br />
pWnd->ReleaseDC(pControlDC);<br />
HOpe someone knows :>
Greetings
Jens
|
|
|
|
|
Hi!
I have a list control and I want to read data from it line by line. I can easily read multiple lines of data if they are selected, like this:
POSITION pos = pList->GetFirstSelectedItemPosition();
if (pos != NULL)
while (pos)
nItem = pList->GetNextSelectedItem(pos);
How do I iterate through all the items whether or not any are selected and whether or not they are visible?
If I could find a function which returned the top-most item, I think I could then use the GetNext() function. There is a GetTopIndex() function but I think that only returns the top-most item that is visible.
Can anyone point out where I am going wrong?
Thank you.
|
|
|
|
|
|
int nCount = GetItemCount();
for (int x = 0; x < nCount; x++)
{
CString strText = GetItemText(x, 0);
}
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Thanks! How did I not see that? It has been a long day perhaps.
|
|
|
|
|
I'm trying to achieve overlapped communication with a device, using a virtual serial port. Basic command-response, where \r\n (CRLF, #013#010) ends both command and response. Multiple commands/responses are chained with ';', no response is given if either the command sets up the device, or the command is invalid.
Ie:
"COMMAND1?\r\n" -> "RESP_TO_1\r\n"
"COMMAND2\r\n" -> no response through serial, but flashes a led on the external device
"COMMAND3;COMMAND4?\r\n" -> "RESP_TO_4\r\n"
"COMMAND5?;COMMAND6?\r\n"-> "RESP_TO_5;RESP_TO_6\r\n"
On W98, using latest VCOM drivers, it works perfect. On XP, WriteFile writes nothing, and GetLastError always returns 997..
997 Overlapped I/O operation is in progress. ERROR_IO_PENDING
I looped the code to check all COM ports, and even the unused IR and VCOM ports are showing up ERROR_IO_PENDING...
I changed timeouts, dcb fields, anything, but 997 keeps haunting me.
So, if anyone using XP, virtual com-ports and OVERLAPPED communication could give me a hand?
I included a piece of sample code. (I left out the part where response is read, since WriteFile never writes anything to respond to anyway)
bool CSerial4::OpenPort(int port)<br />
{<br />
if(port<1) <br />
{<br />
m_sError=_T("Illegal port number");<br />
m_iPort=0;<br />
return false;<br />
}<br />
if(m_hPort!=INVALID_HANDLE_VALUE)<br />
{<br />
return true;<br />
}<br />
else<br />
{<br />
char strPort[15];<br />
sprintf(strPort,"\\\\.\\COM%d",port);<br />
m_hPort = ::CreateFile(strPort,<br />
GENERIC_READ|GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
0
);<br />
if(m_hPort==INVALID_HANDLE_VALUE )<br />
{<br />
m_sError.Format("CommError(%d)",GetLastError());<br />
return false;<br />
}<br />
DCB dcb = {0};<br />
dcb.DCBlength = sizeof(DCB);<br />
<br />
if (!::GetCommState (m_hPort,&dcb))<br />
{<br />
m_sError.Format("GetCommState: CommError(%d)",GetLastError());<br />
return false;<br />
}<br />
<br />
dcb.fRtsControl = RTS_CONTROL_ENABLE;<br />
dcb.fDtrControl = DTR_CONTROL_ENABLE;<br />
dcb.BaudRate = CBR_9600;<br />
dcb.ByteSize = 8;<br />
dcb.Parity = NOPARITY;<br />
dcb.StopBits = ONESTOPBIT;
dcb.EvtChar = 10;<br />
dcb.XoffChar = 19;<br />
dcb.XoffLim = 512;<br />
dcb.XonChar = 17;<br />
dcb.XonLim = 2048;<br />
<br />
<br />
if (!::SetCommState (m_hPort,&dcb))<br />
{<br />
m_sError.Format("SetCommState: CommError(%d)", GetLastError());<br />
return false;<br />
}<br />
<br />
COMMTIMEOUTS timeouts;<br />
timeouts.ReadIntervalTimeout = MAXDWORD; <br />
timeouts.ReadTotalTimeoutMultiplier = 0;<br />
timeouts.ReadTotalTimeoutConstant = 0;<br />
timeouts.WriteTotalTimeoutMultiplier= 0;<br />
timeouts.WriteTotalTimeoutConstant = 0;<br />
<br />
if (!SetCommTimeouts(m_hPort, &timeouts))<br />
{<br />
m_sError.Format("SetCommTimeouts: CommError(%d)",GetLastError());<br />
return false;<br />
}<br />
<br />
DWORD flags=0;<br />
flags|=EV_RXFLAG;
if (!::SetCommMask(m_hPort,flags))<br />
{<br />
m_sError.Format("SetCommMask: CommError(%d)",GetLastError());<br />
return false;<br />
}<br />
<br />
return true;
}<br />
}<br />
<br />
<br />
bool CSerial4::Request(CString in, CString &out)<br />
{<br />
DWORD dwSize=in.GetLength();<br />
DWORD dwBytesWritten=0;<br />
DWORD dwRead;<br />
DWORD dwMask;<br />
char *psp=m_data;<br />
psp[0]=0;<br />
<br />
OVERLAPPED ovRead; <br />
memset(&ovRead,0,sizeof(OVERLAPPED));<br />
ovRead.hEvent=::CreateEvent(0,1,0,0); <br />
<br />
OVERLAPPED ovWrite; <br />
memset(&ovWrite,0,sizeof(OVERLAPPED));<br />
<br />
char* pin=new char[dwSize+1];<br />
strcpy(pin,in);<br />
::PurgeComm(m_hPort,PURGE_TXABORT|PURGE_RXABORT|PURGE_TXCLEAR|PURGE_RXCLEAR);<br />
if(!::WriteFile (m_hPort,pin,dwSize,&dwBytesWritten ,&ovWrite))<br />
{<br />
m_sError.Format("Write Failed: CommError(%d)",GetLastError());<br />
::CloseHandle(ovWrite.hEvent);<br />
return false;<br />
}<br />
...<br />
..<br />
.<br />
|
|
|
|
|
1. The foll code is what I will use.
STARTUPINFO si = { sizeof(STARTUPINFO) }; PROCESS_INFORMATION pi;
Q1. If the exe launched is a windows app that needs some stuff done by the user, and then it is exited, will the WaitForSIngleObject will come back only after this launched windows app terminates?
Q2. If the launched process awaits the user, but he decides to press some other button on the main program (not the launched program) will the button respond? Or will the main app be unresponsive until the user has dealt with the launched app and exited it?
Appreciate your help,
ns
|
|
|
|
|
Q1: Yes
Q2: Depends. If your code is called from the application thread (the one with the message loop), then yes it will block your app until the launched app exits.
But if you call it from an other thread then your app will not block.
Magnus
|
|
|
|
|
i used the MAPI functions in my C++ program to access my inbox and read the mails from it..
the program worked fine only when i open the outlook window..
is MAPI designed in such a way that it works only when the inbox is opened..
iff the window is not opened i get the output as error: could not log on..
can i access the inbox without opening it?iff yes?how do i do that?
ranjani
|
|
|
|
|
Look at MAPILogon() closely, specifically the items dealing with a session.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
The reason for this small test program was that I read on google about a possibility that you could not delete a directory that has a FindFirstChangeNotification watch on it. As it turned out, its no problem at all (at least on WinXP). But I noticed another stranger thing.
When I delete the directory in Explorer, the HANDLE is set to signal state and I get a continuous flow of "Something happened".
But when I delete the directory in Total Commander (new name for Windows Commander) I get error 5 (Access is denied.) from FindNextChangeNotification. And the program ends.
This is not really a question, since the correct implementation should check that the director (or file) you are watching still exists. But what really bothered me were the different results from Explorer and Total Commander. So I wondered if some one else has had this problem or if some one knows why this happens.
Here is the small test program I ran while deleting the directory (its written in Visual Studio 6.0 sp5):
int main( int argc, char* argv[] )
{
HANDLE h = ::FindFirstChangeNotification( "d:\\test\\magnus", FALSE, FILE_NOTIFY_CHANGE_FILE_NAME );
if( h == INVALID_HANDLE_VALUE )
{
std::cout << "Error on FFCN: " << ::GetLastError() << std::endl;
return 0;
}
std::cout << "Entering loop" << std::endl;
for( ;; )
{
DWORD dwWaitState = ::WaitForSingleObject( h, INFINITE );
switch( dwWaitState )
{
case WAIT_OBJECT_0:
std::cout << "Something happened" << std::endl;
break;
case WAIT_ABANDONED:
std::cout << "Error WAIT_ABANDONED" << std::endl;
break;
case WAIT_TIMEOUT:
std::cout << "Error WAIT_TIMEOUT" << std::endl;
break;
default:
std::cout << "Error DEFAULT" << std::endl;
break;
}
if( dwWaitState != WAIT_OBJECT_0 )
break;
if( ::FindNextChangeNotification( h ) == 0 )
{
std::cout << "Error on FNCN: " << ::GetLastError() << std::endl;
break;
}
}
::FindCloseChangeNotification( h );
return 0;
}
Magnus
|
|
|
|
|
hello friends..
I am writing a Wizard application. now i want to change the default focus
i.e if i press enter then the wizard automatically set the Next as default button and as this button gets press the app moves to the next Wizard page.
But in between this i want to change the Default button to Cancel. that means when the user clicks the enter key then instead of the Next the Cancel key should be pressed.
In short i want to change the Default button to Cancel instead of next..
Help
Thanx
TAKE CARE
|
|
|
|
|
One solution is SendMessage().
if (pFromButtom->GetSafeHwnd() && pToButton->GetSafeHwnd())
{
DWORD style = pToButton->GetStyle();
if ((style & BS_DEFPUSHBUTTON) != 1)
{
style = pFromButtom->GetStyle();
// Remove default push button style.
style &= ~BS_DEFPUSHBUTTON;
// Set the new style.
::SendMessage(pFromButtom->GetSafeHwnd(), BM_SETSTYLE, static_cast<wparam>(style), static_cast<lparam>(TRUE));
// Inform the dialog about the new default control ID.
::SendMessage(hWnd, DM_SETDEFID, pToButton->GetDlgCtrlID(), 0);
// Get the style.
style = pToButton->GetStyle();
// Add the default push button style.
style |= BS_DEFPUSHBUTTON;
// Set the new style.
::SendMessage(pToButton->GetSafeHwnd(), BM_SETSTYLE, static_cast<wparam>(style), static_cast<lparam>(TRUE));
}
}
Kuphryn
|
|
|
|
|
Hi kuphryn
Where this code should be written i mean in Initdialog or in PreCreate window ??
Thanx
TAKE CARE
|
|
|
|
|
Put in it stdafx.h. Call it whenever you want to change the default button.
Kuphryn
|
|
|
|
|
I'm not sure, but I think SetDefID(IDCANCEL) would work.
|
|
|
|
|
sorry friend Philnessosity
this doesnt Work !!!!
Thanx
TAKE CARE
|
|
|
|
|
Does anyone have source code that you can give me, or a link to a site, for creating/filtering/manipulating shape files? That is, the file set made up of .shp, .shx, and .dbf files?
It doesn't really look too hard, but I don't want to have to start from scratch.
Thanks,
Dave
"You can say that again." -- Dept. of Redundancy Dept.
|
|
|
|