|
You probably can't, but it depends on the drivers and on the hardware.
On our last project our bluetooth dongles which used virtual com port drivers attached themselves to lowest unoccupied port, or you could manually attach them to a different port using the OS. We found the easiest workaround was to enumerate all available ports and let the user select which one it was connected to.
Alternatively if you've manufactured the hardware yourself you might be able to set up a ping style protocol - loop through all the ports pinging each one in turn and assume that the one which responds is your device.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts your aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Hi,
I tried to create tool tip for my Dialog Box. Everything is working properly. But tooltip is flickering very fastly. I have used PreTranslateMessage(). Please let me know how to solve this.
Thanks in Advance.
If you have faith in the cause and
the means and in God, the hot
Sun will be cool for you.
|
|
|
|
|
Hi,
try with method SetDelayTime of CToolTipCtrl class: it allows you to set the delay time of the tooltip.
Check also msdn on http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_CToolTipCtrl.asp
|
|
|
|
|
Thanks for your advice.
Actaullay at some points on the Dialog Box it is not flickering but at some points on the Dialog Box it is flickering.
Means when ever my mouse is on left side in Dialog Box it will not flicker and when ever I move my mouse to extream right and towords down it is flickering.
Thanks in Advance
If you have faith in the cause and
the means and in God, the hot
Sun will be cool for you.
|
|
|
|
|
I want to put some text on a dialog.
I can either size my text to the dialog or size my dialog to the text. Can anyone tell me how to do this?
I think I will get some text passed to a function. I will then have to format the text into a number of lines with carriage returns and then I will have to create a window large enough to display the text.
So I need to be able to get the size of the text once formatted. How may I do this? Is there a way I can find the screen size of text?
|
|
|
|
|
Well first you'll need to figure the size of the rectangle your text will need to be displayed. You can use one of the text extent function like GetTextExtent(). The problem you will run into here is that the extent function will treat the string as one line, therefor you'll have to call it on a line by line bases. Note that each line my actualy have a different height (based on the characters they contain).
Width = widest line.
Height = tallest line.
From there it should not be to difficult recalculate the dialog size in the OnSize() function.
If you did not want to adjust the size of the dialog box: You could use the above method to see it will fit as is. If it will not fit you could try using GetFont() to retreive the current font (so you don't change selected font type) and the information to create a smaller font that may fit (recalculate and repeat until needed size is reach). Note: You might have to change the font type if this does not work.
I recomend that you look at one of the resizable dialog articles to help you decide what method to use (and how to resize a dialogbox).
Depending on why you need to do this you could just use a mult-line edit control, set to read only, and just copy the text to that.
Good Luck!
INTP
|
|
|
|
|
my prob is that i have a dialog type vc++ application named 'Xyz'.....in this....i have created my own class(CMyclass).....what i want to know is that how shall i can access data of the CXyzDlg class from the CMyclass.....
please help......
|
|
|
|
|
just put a #include "CXyzDlg.h" statement in your CMyClass.h file
|
|
|
|
|
thanx!!!!! ....
|
|
|
|
|
That depends on how you need to use CMyclass.
Is CMyclass only used by the dialog?
#include "CMyclass"
class CMyDialog
{
CMyclass m_myclass;
};
void CMyDialog::func()
{
m_myclass.func();
}
Is CMyclass a globaly declare object (declared some where else)?
#include "CMyclass"
extern CMyclass g_myclass;
void CMyDialog::func()
{
g_myclass.func();
}
Good Luck!
INTP
|
|
|
|
|
thanx!!!!!....
tis helped me....
|
|
|
|
|
When I started a Single-document project 3 years ago I didn't think scrollbars would be needed so I didn't select it in the AppWizard. Resently the need for scrollbars in the main window have arrisen and I can't get it to work. I have tried to change it but the scrollbars just returns to zero when I try to use them. So has anybody done this with success? Please let me know!
I do not want to start the project all over just to add scrollbars, think that will take me more then a week....
|
|
|
|
|
I'm not sure if this will work
Replace all occurences of CView by CScrollView in your CView derived class.
|
|
|
|
|
Tried that already and it doesn't work. Thanks anyway!
|
|
|
|
|
Don't forget to call at startup (for example in OnInitialUpdate of your view class) the function SetScrollSizes.
Normally I think this should work...
|
|
|
|
|
Hi
I urgently need a simple TAPI application in visual C++ that can dial number. On receiving the number, some speech needs to be transfered. I need Visual C++ code in TAPI 3.0 that can transfer speech on the calling (Dialing) number on receiving call.
Thanks from wahaj Khan
|
|
|
|
|
Browse to ftp://ftp.microsoft.com/devloper/tapi
|
|
|
|
|
Hi out there,
I have a strange problem:
I coded a simple Client-Server chat app! It works wonders. The way it works:
The server is a multithreaded app. It waits for incoming connections and if found, start a new thread. There, in an endless loop, it waits for messages.
The Client: It connects to the server, sends its name, so that the server knows who is online. This name will be written down in a lookuptable together with the IP and the socket.
If someone writes a message, the message looks like this: "ToName0FromName: Message". So the server checks if ToName is online, through the lookuptable, and if he is, sending him the Message (after the 0).
Now my problem:
Both clients connect. One starts sending messages. The other one receives them. If the other one sends a message, the first client does receive it. But every following message wont reach the first client. No error messages, nothing. It seems the server doesnt get the message. But, Sending doesnt give any errors, and I checked, and the client is still connected to the server...
If I disconnect this client and connect again, the same thing happens, but the other way around. so the first client cant send, but not the second!
What can this be?
I read alot of papers, and tried alot, but I am still confused!
It would be so nice if you could help me!
DKT
|
|
|
|
|
Hi,
I suggest you to try to debug your application with some watches on the receiveing buffer of the server sockets. What do you mean with "in an endless loop the server waits for messages"? Isn't the server app in idle state?
I was wondering if you used CAsyncSocket class...
|
|
|
|
|
No I am not debugging, changing the active setting to debugging means, I wont be able to debug the app, cause MFC doesnt want to work with threads properly!
With endless loop I mean something like:
while(true)
{
recv(...)
if error break
if done break
else show message
}
No. I am not using this function. I am just listening on a specific port and waiting for incoming connections, if found, start a new thread for it where this loop comes!
DKT
|
|
|
|
|
You may lost some data packets in the server side.
Try to use this thinking:
while(TRUE)
{
select(); // to get socket status
if (SOCKET_ERROR)
{
//deal with the error
//WSAGetLastError() must be called
}
if (TOUT)
{
continue;
}
recv();// after that, you are ready to read some data, because select() was signaled to do something.
}
|
|
|
|
|
Ok, thats fine. I didnt know about select!
Now I get an error code 10022 which means:
"WSAEINVAL
(10022)
Invalid argument.
Some invalid argument was supplied (for example, specifying an invalid level to the setsockopt function). In some instances, it also refers to the current state of the socket—for instance, calling accept on a socket that is not listening."
Now my question. Where didnt I pass the right arguments? I dont use SetSockOpt. I called the select directly after accepting an incoming conncetion, so, before going into the thread! Accept doesnt give any errors. And I know it works, cause I can send msgs.
This is what my accept looks like, or better the whole code up to accept:
if(WSAStartup(MAKEWORD(1,1),&wsaData)!=0)
MessageBox(TEXT("Initialize"), TEXT("Error!"), MB_OK);
local.sin_addr.s_addr=INADDR_ANY;
local.sin_family=AF_INET;
local.sin_port=htons(20248);
if((server_s=socket(PF_INET, SOCK_STREAM, IPPROTO_TCP))==INVALID_SOCKET)
MessageBox(TEXT("SocketCreation"), TEXT("Error!"), MB_OK);
if(bind(server_s, (PSOCKADDR)&local, sizeof(local))==SOCKET_ERROR)
MessageBox(TEXT("Binding"), TEXT("Error!"), MB_OK);
if(listen(server_s, 10)!=0)
MessageBox(TEXT("Listening"), TEXT("Error!"), MB_OK);
else
{
m_con_s="- Connected -";
UpdateData(false);
connect_b=true;
}
while(true)
{
fromlen=sizeof(from);
if((client_s=accept(server_s, (struct sockaddr*)&from, &fromlen))==INVALID_SOCKET)
{
wsprintf (szError, TEXT("Accepting Connections. Error: %d"),
WSAGetLastError ());
MessageBox(szError, "Accepting Connections:", MB_OK);
break;
}
else
if(select(0,0,0,0,0)==SOCKET_ERROR)
{
wsprintf (szError, TEXT("Error: %d"),
WSAGetLastError ());
MessageBox(szError, "Status of Con.", MB_OK);
break;
}
}
Thanks so far!
DKT
|
|
|
|
|
Two more questions:
1. How to use Select? I just set all arguments to NULL, is that correct to get the state of the socket?
2. Can the problem be because I am using just one port for everything, although I am using threads? I mean, every client is connecting on the same port, and get its messages on this port.
DKT
|
|
|
|
|
Does anyone know how can I code a program that logs the mIRC chat window ? Is it possible to code such a program?
I saw that the mIRC chat window class name is "Static" and I tried to get tha handle to the window and I sent a WM_GETTEXT message but it didn't work.
Please help me!!!
Cristian
|
|
|
|
|
Hello everyone:
Are there any functions fast than sccanf, sprintf, strlen?
Thanks.
-Freehawk
|
|
|
|