|
SNArruda wrote: Some one knows what i need read or learn to create this kind of program ?
Well, as others Identified, this is a Firewall Issue. Your best way forward would be to study Firewall Technology. It has the ability to Pass or Block Network messages, depending on Origin and Contents.
Another solution is an ordinary Central Heating Timer, which interrupts the Telephone Line to the Computer for the barred period(s). Look at the POTS Spec for this. There are various ways to skin a cat, not all of these involve Software.
Bram van Kampen
|
|
|
|
|
Hi,
I am very confused to why this isn't working.
My starting window width size is 756
I got this result by declaring:
CRect Rect;
GetClientRect(&Rect);
Rect.Width();
I divide the 756 / 2 to plae the triangle in the centre of the
window. I have set up a message handler for the left and right
arrow key press, which moves the triagle by 10.
if the user resizes the the window, the window should
display in proportion, by the statement.
widthRatio = Rect.Width() / 756;
then * the x posistion by the widthRatio
I have tried declaring the variables 'float, double, and int
I can not seem to find a reason why this shouldn't work
the posistion remains the same if I expand, and snaps to the
left hand of the screen if the size has gone smaller
does anybody know whats going on
cheers Simon
|
|
|
|
|
simon alec smith wrote: I can not seem to find a reason why this shouldn't work
What doesn't work? What value does widthRatio contain? Since both the numerator and the denominator are integers, it will likely contain 0 . Try dividing my 756.0 instead.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Thank you very much, I have tried 756.0 and it works
it would of taken me a hundred years to work that one out
cheers
|
|
|
|
|
Modified for the 2nd time... Looks like I missed the point with your question - dividing an integer with another integer, especially a larger one is going to give you BAD results. - Iain.
Where are you doing these calculations?
class CMyView : public CView
{
...
int m_nHorzOffset;
...
};
void CMyView::OnDraw(CDC* pDC)
{
CRect rc;
GetClientRect (&rc);
CPoint ptCentre = rc.CenterPoint ();
ptCentre.x = rc.Width () / 4;
pDC->MoveTo (ptCentre.x, rc.top);
pDC->LineTo (ptCentre.x, rc.bottom);
pDC->MoveTo (ptCentre.x + m_nHorzOffset - 100, ptCentre.y + 50);
pDC->LineTo (ptCentre.x + m_nHorzOffset + 100, ptCentre.y + 50);
pDC->LineTo (ptCentre.x + m_nHorzOffset, ptCentre.y - 100);
pDC->LineTo (ptCentre.x + m_nHorzOffset - 100, ptCentre.y + 50);
}
...
void CMyView::OnLeftABit ()
{
m_nHorzOffset -= 10;
Invalidate ();
}
I'm assuming you have the left arrow mapped via an accelerator to (eg) IDC_LEFTABIT, and have a command handler called OnLeftABit in your view class.
Hopefully that should work.
Iain.
Modified: Added centre line, some comments, and x=width/4 as an example.
modified on Thursday, September 18, 2008 12:07 PM
|
|
|
|
|
In addition to DavidCrow's reply...
simon alec smith wrote: widthRatio = Rect.Width() / 756;
then * the x posistion by the widthRatio
When working with integers like this, you can often rearrange the
calculation to avoid getting the 0. Do the multiply first, then the
divide. This way you can avoid floating point types which can give better
performance in certain situations.
Of course, if you need the ratio variable in other places, then you'll
need to make sure you do a floating point calculation as DavidCrow showed.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello everyone,
I want to implement the shake hands of Windows Integrated Authentication for myself. Here is a reference link of the protocol and steps of shakehands.
http://en.wikipedia.org/wiki/NTLM
I have tried a prototype using WinInet API below, and find each time when using WinInet API InternetOpenUrl, this API will handle all underlying authentication shakehands for me. :wave:
http://TestMachine/Monitor is a web site setup by IIS with Windows Integrated Authentication, and the following invocation of InternetOpenUrl will automatically returns 200 OK and will use my current login user's credential automatically -- no change for me to parse return each time from IIS and do the shakehands by myself.
My question is, could I use WinInet level API like InternetOpenUrl to achieve my goal? Why?
My simple code.
#include <stdio.h>
#include <stdlib.h>
#include <winsock2.h>
#include <wininet.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
int main()
{
HINTERNET hINet = InternetOpen(TEXT("InetURL/1.0"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
if ( !hINet )
{
return EXIT_FAILURE;
}
HINTERNET hFile = InternetOpenUrl( hINet, TEXT("http://TestMachine/Monitor"), NULL, 0, 0, 0 );
if(hFile)
{
CHAR buffer[1024]={0};
DWORD dwRead;
while ( InternetReadFile( hFile, buffer, 1023, &dwRead ) )
{
if ( dwRead == 0 )
break;
buffer[dwRead] = 0;
cout << buffer << endl;
}
InternetCloseHandle( hFile );
}
InternetCloseHandle(hINet);
return EXIT_SUCCESS;
}
thanks in advance,
George
|
|
|
|
|
Hi,
Is there a simple way to draw dashed lines with a width greater than 1 pixel on a DC?
CPen will not allow a PS_DASHED style with a width of more than 1.
TIA
|
|
|
|
|
LOGBRUSH lb;
lb.lbStyle = BS_SOLID;
lb.lbColor = RGB(0,0,0);
CPen newPen(PS_GEOMETRIC | PS_DASHED , 2, &lb);
For a dashed pen with a width of 2.
|
|
|
|
|
Cheers Cédric thats just what I was looking for!
|
|
|
|
|
I have a CSpinButtonCtrl as a resource in a dialog and I made a variable out of it using GetDlgItem. I compiled the code using WDK6000 on winXP and it compiled without any error.
But when i tried to compile it on win 98, using 95 DDK. I am getting an error :
CSpinButtonControl : undeclared identifier
I have a line in the code like this:
CSpinButtonCtrl *spinobj = (CSpinButtonCtrl *)GetDlgItem(IDC_SPN_COPY);
//IDC_SPN_COPY is the resource id.
I have declared the IDC_SPN_COPY in a header file i am using.
I tried adding #include<afxcmn.h>, but it again gave an error which is like :
cannot open afxcmn.h file.
somebody please help me out..
|
|
|
|
|
I tried adding #include<afxcmn.h>, but it again gave an error which is like :
cannot open afxcmn.h file.
|
|
|
|
|
it looks like the CSpinButtonCtrl came later than 95 DDK.
Google it out...
Update your life
Greetings from Germany
|
|
|
|
|
Man I have tried every possible way
|
|
|
|
|
Ehh, have I understood you correctly; you're building user mode applications with the Driver Kit?
I don't say it's impossible since I think it's the same compiler and linker, but I would consider the environment the wrong tool for the job.
Do you have an existing installation of some Visual Studio version?
Otherwise I doubt you even have the file you're trying to include on your disk.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
yes, i have visual studio 6 and SDK installed on the 98 system.
I am want a spin control on my printer driver UI.
I am getting the error :
CSpinButtonControl : undeclared identifier.
and I read in msdn that afxcmn.h header is for mfc common control.
so, i tried including the header, now it is giving this error.
fatal error C1083: Cannot open include file: 'afxcmn.h': No such file or directory
|
|
|
|
|
tenwang wrote: I read in msdn that afxcmn.h header is for mfc common control.
That's correct, but are you building with support for the MFC framework?
Do you include e.g. afxwin.h anywhere in your source code?
I'm not sure I can help you further, I've never built anything user mode related with any WDK/DDK.
Furthermore I'm not sure what you're trying to do; you're talking about a "printer driver UI", but a driver doesn't have a UI. You may mean a Control Panel application meant to control the driver settings and if that's the case you can check out the WDM sample "Sample Audio Control Panel Application" in the WDK help.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
what i mean was, user interface for the printer driver, i need a spin control for various edit controls, like one for entering no. of copies to be printed.
afxwin.h is included in my code, the thing is that, my code works without error in xp, using wdk environment.
as i m using(i have to) DDk for 98, so i m facing this problem.
|
|
|
|
|
afxcmn.h and afxwin.h are located in the same directory, so if you can successfully include afxwin.h you shouldn't have any problem finding the afxcmn.h file.
Try building without the CSpinButtonCtrl and see if this is the only include problem you have and to verify that you can successfully include the afxwin.h file.
I assume you've included the file by writing...
#include <afxcmn.h> ...and not...
#include "afxcmn.h" ...so the compiler can search the include path instead of assuming the file is located in the project directory.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Yes, I used #include <afxcmn.h>, and i tried without CSpinButtonCtrl in my code, the it gives error for the header file.
I am using afxwin.h since long time back, and i have been using mfc classes like cbutton and cdialog without any hitch.
only after the problem with the CSpinButtonCtrl, i included afxcmn.h. I think, ddk is not having a library which wdk has.
thanks for ur concern...
|
|
|
|
|
I have used the below code to determine the Host Name of the local machine in which the application is running. gethostname() function returns SOCKET_ERROR. The same code works fine in another application. Pls tell me why it is not working in my application. Should I change any Project settings.
SOCKADDR_IN sockAddr;
memset(&sockAddr,0,sizeof(sockAddr));
CString rSocketAddress;
LPHOSTENT lphost;
char HostName[80];
if (gethostname(HostName, sizeof(HostName)) == SOCKET_ERROR)
{
AfxMessageBox(WSAGetLastError());
PostQuitMessage(WM_QUIT);
}
//_tcscpy(mInstSess[ind].INSHost,HostName);
m_sInsHost = HostName;
lphost = gethostbyname(HostName);
if (lphost != NULL)
{
sockAddr.sin_addr.s_addr = ((LPIN_ADDR)lphost->h_addr)->s_addr;
rSocketAddress = inet_ntoa(sockAddr.sin_addr);
//strcpy(mInstSess[ind].INSIP,rSocketAddress);
m_sInsIP = rSocketAddress;
}
Thanks in advance
Anusuya
Anu
|
|
|
|
|
Anu_Bala wrote:
if (gethostname(HostName, sizeof(HostName)) == SOCKET_ERROR)
{
AfxMessageBox(WSAGetLastError());
PostQuitMessage(WM_QUIT);
}
So what does WSAGetLastError() tell you?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
It simply printed m in the messagebox
The function returned -1
Anu
|
|
|
|
|
Anu_Bala wrote: The function returned -1
What? -1?
Here are the error codes and I don't see -1 in it: Windows socket error codes[^]
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
AfxMessageBox() takes either a string to display, or a resource ID corresponding to a post in the string table as argument.
Since you're passing the return value from WSAGetLastError() , which is an integer value, the AfxMessageBox() function will try to load the string that matches that ID from the string table. Likely that ID does not exist in the string table and the call fails, hence the "-1".
Assign the return value from WSAGetLastError() to a variable and debug your code.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|