|
|
Hi,
I have a Win32 Console Application. I am using VC 6.0
My program is a TCP based Client Server Aplication. In the Server part, I have a variable defined for SOCKADDR_IN.
SOCKADDR_IN saServer;
LPHOSTENT lpHostEntry = gethostbyname(clientIP);
saServer1.sin_family = AF_INET;
saServer1.sin_addr = *((LPIN_ADDR)*lpHostEntry->h_addr_list);
saServer1.sin_port = htons(3500);
Then, when I am running the program, binding error occurs. This is when I am trying with the server and client programs in different machines. But in the localhost, it is working.
But, if I am trying it with address set to INADDR_ANY, it is working(both in the localhost and with different machines).
saServer1.sin_addr.s_addr = INADDR_ANY ;
Why does this happen? Actually I am confused. Is there any problem with binding a socket to a port with a known address or what is the difference between the two scenarios?.
Please can anyone help me?
|
|
|
|
|
Vichitram wrote: Is there any problem with binding a socket to a port with a known address
No, as long as you know the correct address to bind to.
Generally you only need to know the address to connect to. INADDR_ANY is generally fine for the
bind address unless you need to bind to a certain NIC.
Is the code you posted initializing a local address or a remote address?
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Thank you very much ,WhiteSky ! But can i set a picture to Desktop by Api function ? Please help me !
Regards and thank !
|
|
|
|
|
|
Hello.
I am trying to get the coordinates of the clicked point inside a picture control on a dialog. For the picture control, I have derived my own class based on CStatic. And I have set the picture control style to Notify. I have created OnLButtonDown method in the Dlg.
The problem is when I clicked on the picture, the coordinates are not passed down but when I clicked on other part of the dialog, the coordinates are passed down.
Can anyone help me in this? I want to get the coordinates of the picture.
|
|
|
|
|
Where do you use of GetCursorPos on your program for get position?
|
|
|
|
|
When I use GetCursorPos in the dlg in the OnPicture method, i can get the coordinates. But it is the coordinates of the dialog, not the coordinates of the picture. And also i want to get the coordinates when the left button is down and when the left button is up. How do i go abt in doing this?
|
|
|
|
|
ReturnRain wrote: When I use GetCursorPos in the dlg in the OnPicture method, i can get the coordinates. But it is the coordinates of the dialog, not the coordinates of the picture
GetCursorPos() will return the x,y points with respect to screen coordinates.
Change those to clinet coordinates. say, m_wndMyStatic is your derived static class variable,then
POINT pt = {0};
GetCursorPos( &pt );
m_wndMyStatic.ScreenToClient( &pt );
ReturnRain wrote: And also i want to get the coordinates when the left button is down and when the left button is up. How do i go abt in doing this
Handle WM_LBUTTONDOWN and WM_LBUTTONUP and do the above. You can get the rect..
Hope this will help
Do your Duty and Don't expect the Result
|
|
|
|
|
Thanks! I can get the first part right. But Im confused with the WM_LBUTTONDOWN and WM_LBUTTONUP. Since i want the picture coordinates when the button is down, should i put the codes in OnLButtonDown or OnPicture (picture control)? And just to make sure, OnLButtonDown and OnLButtonUp is in the dlg?
|
|
|
|
|
You must get position on the picture class (if you derived a CStatic class)
|
|
|
|
|
Your picture control is a seperate child window to the dialog, so mouse click message is generated and sent to static window, then the static window send WM_NOTIFY message to the parent dialog window, when ur mouse clicks on static control rather than clicking on dialog window. I recommand u to handle this by overwrite CStatic::OnLButtonDown or handle it by CYourDialog::OnNotify. hope this could help u out.
life is like a box of chocolate,you never know what you r going to get.
|
|
|
|
|
Hello
I have a gradient-like background with an owner drawn button. I use AlphaBlend() to draw button's image. Now, the strange thing is:
Background pixel = RGB(168,168,168)
Source pixel = 0xFFFF0000 (AARRGGBB)
After AlphaBlend() with SourceConstantAlpha=0xff the output is RGB(255,0,0) - that's correct but when I change a bit the source pixel to
Source pixel = 0x00FF0000 (AARRGGBB)
I receive pixel RGB(255,168,168)?!?! I should get RGB(168,168,168) because the source alpha is 0x00?!?!?
After some tests with different RGB values, I noticed that my blending works like it 'thinks' that my background is white (255,255,255)?!? When I make all source pixels to have 0xFF alpha value and just play with SourceConstantAlpha value, it's working fine!?! - my button is drawn with proper transparency?!?
I need to play a bit with the source pixels' alpha value for 'soft' button's border.
Does anyone know what could be wrong?? I'm using winxp/vs2003
Thanks a lot!!
|
|
|
|
|
AlphaBlend() from which class?
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Sorry, I couldn't reply as I was offline for couple of days. I was trying CDC::AlphaBlend(), CImage::AlphaBlend() and global ::AlphaBlend() with the same results.
I discovered that I should premultiply r/g/b values by alpha channel. Now it works fine, but I wonder how to cope with the situation when You have very small r/g/b values and small alpha channel. When You premultiply those small values and divide by 255, You will get zeroes...Now if You want to recover almost transparent pixels by increasing their alpha value, You will get black color instead of original one?!?!?
Am I correct??
Simple example:
Source bitmap: ARGB(10,20,0,0) ; DARK RED
After premultiply: ARGB(10,20*10/255,0,0) = ARGB(10,0,0,0); BLACK
Now try to recover original color by increasing alpha
ARGB(255,0,0,0) and You receive black instead of ARGB(255,20,0,0);
Thanks for Your attention.
|
|
|
|
|
Since you're essentially dividing pixel RGB values by 25.5 then yes, any values less than 25 are
going to end up being 0.
There's still something strange - I'm going to try your original code so I can see it.
I'll be back.
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Hi...
I have a program written in MVS2005 (C++) - a form application. When I run it, it works just fine. But when I try to run the application on a computer without MVS installed it gives me this error: "This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem".
Now... The computer I'm trying to run the application on has .NET Framework 2.0 installed, and my application has all the .dll-s needed in the same folder. I also tried with a Visual 2005 Redistributable package, but the error still pops up. I searched the internet for a solution and I found out I was supposed to include the dlls in my .exe . I did that, but still no result.
Can anyone please tell me how to make an application compatible with all computers (at least running on XP with SP2 and .NET framework 2 installed)?
|
|
|
|
|
Check the dependency of your executable. For checking dependency you need depends.exe, it can be found at MS VS6.0 installation.
Regards,
Paresh.
|
|
|
|
|
I'm an extreme beginner to C++... how do I clear data that I have the user input? Is there an easy function to do this? If I don't know how to do this should I even bother trying to ever learn C++?
Like you imagined when you were young...
|
|
|
|
|
eRose24 wrote: how do I clear data that I have the user input?
What kind of user input you are talking about ? Can you be a little clear ?
|
|
|
|
|
Can you say more explain what kind input?
|
|
|
|
|
Hello,
I have created a non doc-view application.In this MDI application I have a childview derived from CWnd.The window is created with window styles as WS_VSCROLL | WS_HSCROLL. And so I am getting vertical and horizontal scroll bars along with the window.
If I write the OnVScroll and OnHScroll function the pScrollbar pointer is NULL.
so I cannot handle any functions of pScrollbar .How to attach the pointer of CScrollbar to the scrollbar that I have with the window.
Prithaa
|
|
|
|
|
You can use CWnd::GetScrollInfo()/CWnd::SetScrollInfo() to manipulate the window's scrollbars.
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Hello,
Yes I have been to the Scrolling functions of CWnd class but once the window is made how are the pointers for the scroll bars attached to the scroll bars that I can see with the window.
It seems that the pointer is NULL for CScrollbar *pScrollbar which comes up when I call the function ONHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
And if I want to access the SetScrollRange in the OnCreate
function I get access violation error
Prithaa
with
|
|
|
|
|
For built-in scrollbars (WS_HSCROLL/WS_VSCROLL):
You don't use the CScrollbar pointer (obviously, since it's NULL).
For the CWnd::GetScrollRange/CWnd::SetScrollRange/CWnd::GetScrollInfo/CWnd::SetScrollInfo/etc.
methods, use SB_HORZ/SB_VERT for the nBar parameter to access the appropriate scrollbar.
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|