|
InternetGetConnectedState
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks guys -
I don't think either one will work though.
The reason why InternetGetConnectedState won't work is that it seems to only detect if a connection to the internet is found. This won't be true since by default, any new PC will not be allowed to connect to the internet from within our building (MAC filtering).
What I need is a way to determine if the connection is good for a particular interface. Similar to what the connection status icon does in XP.
For now, I'm using a ping to our server name. I guess it's about as good as I will be able to do.
If anyone has a better suggestion, please let me know.
|
|
|
|
|
Is this of any help?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
lynchspawn wrote: Any idea how they are doing it?
ISensNetwork
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hello all! This is a duplicate from the SQL forum. It might be more suited for this forum.
I've recently completed a Pocket PC application in VB.NET that works with connections to a local SQL Server 2000 CE DB and a SQL Server 2000 via WiFi.
I'd like to look at doing the same thing using eMbedded Visual C++ 4.0 and OLE DB for a CE.NET device. While there are plenty of resources for SQL CE I can't find any for SQL Server 2000.
Does anyone know of a good sample for eVC++ that hits both SQL CE and SQL Server? No ActiveSync and no IIS for this solution thus RDA and Merge Repl are of no value.
Any input is much appreciated!
|
|
|
|
|
Hi,
My problem is that I can't make the size of the toolbar buttons right.
This is my code:
HWND CreateMyToolbar(HWND hWnd)<br />
{<br />
HWND hToolbar;<br />
hToolbar = NULL;<br />
hToolbar = CreateWindowEx(0,TOOLBARCLASSNAME,"MyToolbar",WS_CHILD|WS_VISIBLE|TBSTYLE_TOOLTIPS ,0,0,0,0,hWnd,0,g_hInstance,NULL);<br />
if(hToolbar)<br />
{<br />
SendMessage(hToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);<br />
TBBUTTON tbb[1];<br />
TBADDBITMAP tbab;<br />
tbab.hInst = HINST_COMMCTRL;<br />
tbab.nID = IDB_STD_LARGE_COLOR; <br />
SendMessage(hToolbar, TB_ADDBITMAP, 0, (LPARAM)&tbab);<br />
<br />
ZeroMemory(tbb, sizeof(tbb));<br />
<br />
tbb[0].iBitmap = STD_FILENEW;<br />
tbb[0].fsState = TBSTATE_ENABLED;<br />
tbb[0].fsStyle = TBSTYLE_BUTTON;<br />
tbb[0].idCommand = IDM_FILENEW; <br />
<br />
SendMessage(hToolbar, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb);<br />
return hToolbar;<br />
}<br />
return NULL;<br />
<br />
}
I've set the IDB_STD_LARGE_COLOR imagelist, but in the result the button image is clipped on the bottom.
Can someone show me how to do this right?
thanks in advance,
Ward
|
|
|
|
|
Ok, I figured it out by myself. Finally.
Ward
|
|
|
|
|
Hello,
Would like to know how the contents of a control (say edit control / text box) can be sent to a printer. I am having a text box which is in a dialog. Normally print is supported for a view. But my requirement is to extract the contents of the control, which is in a VC++ 6.0 dialog and has to be printed.
Will help a lot, if a sample code is supported.
Regards,
Vairamuthu.G.
|
|
|
|
|
Hi,
Use following code:
DOCINFO di = { sizeof (DOCINFO) } ;<br />
PRINTDLG pd ;<br />
int yChar, iCharsPerLine, iLinesPerPage, iTotalLines, iTotalPages, iPage, iLine, iLineNum ;<br />
PTSTR pstrBuffer ;<br />
<br />
TCHAR szJobName [64 + MAX_PATH] ;<br />
TEXTMETRIC tm ;<br />
WORD iColCopy, iNoiColCopy ;<br />
<br />
pd.lStructSize = sizeof (PRINTDLG) ;<br />
pd.hwndOwner = hwnd ;<br />
pd.hDevMode = NULL ;<br />
pd.hDevNames = NULL ;<br />
pd.hDC = NULL ;<br />
pd.Flags = PD_ALLPAGES | PD_COLLATE | PD_RETURNDC | PD_NOSELECTION ;<br />
pd.nFromPage = 0 ;<br />
pd.nToPage = 0 ;<br />
pd.nMinPage = 0 ;<br />
pd.nMaxPage = 0 ;<br />
pd.nCopies = 1 ;<br />
pd.hInstance = NULL ;<br />
pd.lCustData = 0L ;<br />
pd.lpfnPrintHook = NULL ;<br />
pd.lpfnSetupHook = NULL ;<br />
pd.lpPrintTemplateName = NULL ;<br />
pd.lpSetupTemplateName = NULL ;<br />
pd.hPrintTemplate = NULL ;<br />
pd.hSetupTemplate = NULL ;<br />
<br />
if (!PrintDlg (&pd))
return TRUE ;<br />
<br />
if (0 == (iTotalLines = SendDlgItemMessage (hwnd,IDC_TEKSTVELD, EM_GETLINECOUNT, 0, 0)))<br />
return TRUE ;<br />
<br />
GetTextMetrics (pd.hDC, &tm) ;<br />
yChar = tm.tmHeight + tm.tmExternalLeading ;<br />
<br />
iCharsPerLine = GetDeviceCaps (pd.hDC, HORZRES) / tm.tmAveCharWidth ;<br />
iLinesPerPage = GetDeviceCaps (pd.hDC, VERTRES) / yChar ;<br />
iTotalPages = (iTotalLines + iLinesPerPage - 1) / iLinesPerPage ;<br />
<br />
pstrBuffer = (PTSTR)malloc (sizeof (TCHAR) * (iCharsPerLine + 1)) ;<br />
<br />
<br />
di.lpszDocName =
<br />
if (StartDoc (pd.hDC, &di) > 0)<br />
{<br />
for (iColCopy = 0 ;<br />
iColCopy < ((WORD) pd.Flags & PD_COLLATE ? pd.nCopies : 1) ;<br />
iColCopy++)<br />
{<br />
for (iPage = 0 ; iPage < iTotalPages ; iPage++)<br />
{<br />
for (iNoiColCopy = 0 ;<br />
iNoiColCopy < (pd.Flags & PD_COLLATE ? 1 : pd.nCopies);<br />
iNoiColCopy++)<br />
{<br />
if (StartPage (pd.hDC) < 0)<br />
{<br />
bSuccess = FALSE ;<br />
break ;<br />
}<br />
for (iLine = 0 ; iLine < iLinesPerPage ; iLine++)<br />
{<br />
iLineNum = iLinesPerPage * iPage + iLine ;<br />
<br />
if (iLineNum > iTotalLines)<br />
break ;<br />
<br />
*(int *) pstrBuffer = iCharsPerLine ;<br />
<br />
int iAantalChars = (int) SendDlgItemMessage (hwnd,IDC_TEKSTVELD, EM_GETLINE,<br />
(WPARAM) iLineNum, (LPARAM) pstrBuffer);<br />
<br />
<br />
TextOut (pd.hDC, 0, yChar * iLine, pstrBuffer, iAantalChars);<br />
<br />
if (EndPage (pd.hDC) < 0)<br />
{<br />
break ;<br />
}<br />
<br />
<br />
}
<br />
}<br />
<br />
free (pstrBuffer) ;<br />
DeleteDC (pd.hDC) ;
This will surely help you.;)
kind regards,
Ward
|
|
|
|
|
I have function in a class called LoadFile
BOOL Bitmap::LoadFile(const char *FileName)<br />
{<br />
<br />
CFileException e;<br />
<br />
strcpy(m_FileName,FileName);<br />
<br />
}
to which i pass string during the call
const char *FileName= _T("c:\\1.bmp");<br />
BMP.LoadFile (FileName);
there is an error
error: unhandled exception , 0x0000000005 access violation
whats wrong
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
What is m_FileName ?
It seems to be something like:
char* m_FileName; //This should produce the error.
However,
char m_FileName[MAX_PATH];//This should not result in an error.
It is unclear from your post; it could be something else also.
this is this.
|
|
|
|
|
What is m_FileName declared as?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for - in order to get to the job you need to pay for the clothes and the car, and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
|
|
|
|
|
It depends on what data type m_Filename is.
If it is of type CString, then I think this function will not work without first exposing the memory buffer (GetBuffer(0) ??).
If the variable is an array of characters, then it should work (unless the destination size is less than the source string).
I Dream of Absolute Zero
|
|
|
|
|
vikas amin wrote: strcpy(m_FileName,FileName);
change to
if ((!m_FileName) && (size_allocated_to(m_FileName) > ::strlen(FileName))) {
::strcpy(m_FileName, FileName);
}
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|
|
Ok
I think i got the point
i need to allocate the space for
the destination .
thank you
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
see if u have initialized it first. like khan said
regards,
Rookie
Installing MFC...2% complete
|
|
|
|
|
Hello,
You should beware of the UNICODE problems that your code have when you compile with UNICODE defined. See the following where your problems are:
const char* FileName
= _T("C:\\1.bmp");
To solve this problem, use TCHAR* instead of char* where you want to use the _T macro.
[EDIT]
You should also use the macros from tchar.h[^] so that you use UNICODE functions when you build with UNICODE defined.
[/EDIT]
Hope this helps.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
-- modified at 9:43 Tuesday 20th December, 2005
|
|
|
|
|
Hey. If m_FileName happens to be a CString, then just do this instead:
mFileName = FileName
instead of using anything like strcpy.
You are LUCKY you got the access violation now and not 10 months from now with 10 million copies of your app in the field
No shirt, no shoes, no brains, no service.
|
|
|
|
|
|
Show me EXACTLY here the m_FileName is defined or declared in his original post?
No shirt, no shoes, no brains, no service.
|
|
|
|
|
Since you are using mfc why not use CString and let all this memory allocation for strings automatically be handled for you??
John
|
|
|
|
|
vikas amin wrote: strcpy(m_FileName,FileName);
Why are you not using CString ?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
vikas amin wrote: strcpy(m_FileName,FileName);
Hai Vikas,
what type of variable is m_FileName
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I have a class in which there is a structe
i want to initialize the structre through the constructer .
class xyz{
struct tagBITMAPFILEHEADER
{
WORD bfType; // must be 'BM'
DWORD bfSize; // size of the whole .bmp file
WORD bfReserved1; // must be 0
WORD bfReserved2; // must be 0
DWORD bfOffBits;
}m_BITMAPFILEHEADER ;
xyz()
{
BITMAPFILEHEADER ={0,0,0,0,0};
}
}
I am getting an error
error C2059: syntax error : '{'
error C2143: syntax error : missing ';' before '{'
am i wrong someware
}
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
If the code that you post is the real code there is a little error:
vikas amin wrote: xyz()
{
BITMAPFILEHEADER ={0,0,0,0,0};
}
xyz()
{
m_BITMAPFILEHEADER ={0,0,0,0,0};
}
Have a nice code day
|
|
|
|
|