|
Hi,
bascially i have an IP Address contained in a CString "10.10.10.1"
i need a unsigned long representation of it.
here is the function im using below but
im not sure, if its right..
its hit and miss, works sometimes not others..
can anyone recommend an easier way of doing it
or point out errors in the function
int check1;
CString m_ipSrc;
unsigned long srcIp
check1 = convertAddress(m_ipSrc, &srcIp)
int DlgClass::convertAddress(const char *sIp, unsigned long *lIp)
{
int octets[4];
int i;
const char * auxCad = sIp;
*lIp = 0;
for(i = 0; i < 4; i++)
{
octets[i] = atoi(auxCad);
*lIp |= (octets[i] << (i*8));
auxCad = strchr(auxCad, '.');
auxCad++;
}
return 0;
}
|
|
|
|
|
|
I have created a dialog to handle the joystick inputs, just to check that I obtain the data.
However the move joystick and joy button changed events dont seem to be firing.
BEGIN_MESSAGE_MAP(CMSCPPDlg, CDialog)
//{{AFX_MSG_MAP(CMSCPPDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_GET_STATUS, OnGetStatus)
ON_BN_CLICKED(IDC_START, OnStart)
//}}AFX_MSG_MAP
ON_MESSAGE(MM_JOY1BUTTONDOWN, OnJoy1ButtonDown)
ON_MESSAGE(MM_JOY1BUTTONUP, OnJoy1ButtonUp)
ON_MESSAGE(MM_JOY1MOVE, OnJoy1Move)
END_MESSAGE_MAP()
I start the capture via:
void CMSCPPDlg::OnStart()
{
/* This procedure starts or stops the capture of the Joystick movement and
button presses. */
static bool capture = false;
int error;
if(!capture)
{ // Start the capture
error = joySetCapture(this->m_hWnd, JOYSTICKID1, NULL, FALSE);
if (error == MMSYSERR_NODRIVER)
MessageBox("The joystick driver is not present", "Error when capturing", MB_ICONERROR);
if (error == MMSYSERR_INVALPARAM)
MessageBox("Windows 95/98/Me: Invalid joystick ID or hwnd is NULL.", "Error when capturing", MB_ICONERROR);
if (error == JOYERR_NOCANDO)
MessageBox("Cannot capture joystick input because a required service (such as a Windows timer) is unavailable.", "Error when capturing", MB_ICONERROR);
if (error == JOYERR_UNPLUGGED)
MessageBox("The specified joystick is not connected to the system. ", "Error when capturing", MB_ICONERROR);
else
{
MessageBox("The joystick has been captured");
capture = true;
}
}
else
{ // Release the Joystick capture
joyReleaseCapture(JOYSTICKID1);
capture = false;
MessageBox("The joystick has been released");
}
}
I have placed breakpoints in the OnJoy1Move & JOY1BUTTONDOWN and they are never reached.
grahamfff
|
|
|
|
|
I have a question. Which one of these is a faster network architecture: using blocking calls with a multithreaded pool or just using the asynchronous protocol?
|
|
|
|
|
Hi guys!
I have a MDI programm. and now, i want to call a function in CSampleViw which is in cmainframe. the function makes a new childframe.
how could I do that?
<br />
void CMainFrame::OnStartRenderView()<br />
{<br />
CMDIChildWnd* pActiveChild = MDIGetActive();<br />
CDocument* pDocument;<br />
if (pActiveChild == NULL ||<br />
(pDocument = pActiveChild->GetActiveDocument()) == NULL) {<br />
TRACE("Warnung: Kein aktives Dokument für WindowNew vorhanden\n");<br />
AfxMessageBox(AFX_IDP_COMMAND_FAILURE);<br />
return;
}<br />
<br />
CDocTemplate* pTemplate =<br />
((CSampleApp*) AfxGetApp())->m_pTemplateRender;<br />
ASSERT_VALID(pTemplate);<br />
CFrameWnd* pFrame =<br />
pTemplate->CreateNewFrame(pDocument, pActiveChild);<br />
if (pFrame == NULL) {<br />
TRACE("Warnung: Neuer Rahmen konnte nicht erstellt werden\n");<br />
AfxMessageBox(AFX_IDP_COMMAND_FAILURE);<br />
return;
}<br />
<br />
pTemplate->InitialUpdateFrame(pFrame, pDocument);<br />
}<br />
|
|
|
|
|
If I understand correctly, you want to call OnStartRenderView() from CSampleView . To do this, make sure the method is declared public in your mainframe class. Then, do this in your view class:
((CMainFrame *) AfxGetMainWnd())->OnStartRenderView();
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I am programming a dialog box in MFC. Is there a way that I can have my dialog application open up a game window? For example, my dialog is the active window, and Counter Strike is alt tabbed. Is there a way that I can:
1. See if CS is alt tabbed
2. Open up CS from my dialog
I have tried using SetActiveWindow(), but I can't seem to make a pointer to CS. Any help would be great.
-Dev578
|
|
|
|
|
When you say open up, are you referring to executing a program or set a window active?
Kuphryn
|
|
|
|
|
Setting the window active. Sorry, should have been more clear. The program is already running, I just want to make it the active window.
-Dev578
|
|
|
|
|
You will need to get the HWND of the other window. You can do this several ways, either by calling EnumWindows once you have defined a EnumWindowsProc callback or use FindWindow to get the HWND .
- Nick Parker My Blog
|
|
|
|
|
I am using this code
while (ERROR_SUCCESS == RegEnumValue(theSettings._rgk,dwIdx,szValueName, &dwValueNameLen,NULL,&dwType,(LPBYTE)buff,
&dwSize))
{
pairVec.push_back(std::make_pair(_bstr_t(szValueName),_bstr_t(buff)));
dwIdx++;
}
i have 5 entries in the registry, the above loop only finds the last one and
then exits.....
can any1 help?
thanks
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
You need to reset dwValueNameLen and dwSize to the sizes of your buffers before each call to RegEnumValue()
--Mike--
Personal stuff:: Ericahist Updated Feb 6! | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2
Pinky, are you pondering what I'm pondering?
I think so Brain, but how will we fit the hamster inside the accordion?
|
|
|
|
|
thanks
works like a charm
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Hi..
i am developing an vc++ application that manage files
(copy ,move and rename)and i am useing the CFileFind
class but an error keep arise each time i make run
error name:assertion failures
in line 354 which is
void CFileFind::AssertValid() const
{
if (m_hContext == NULL)
ASSERT(m_pFoundInfo == NULL && m_pNextInfo == NULL);
else
(354) ASSERT(m_pFoundInfo != NULL && m_pNextInfo != NULL);
}
i read a bout it in the help but i still can not solve it ..
so an idea to help me..
|
|
|
|
|
Post the code that makes use of CFileFind.
Kuphryn
|
|
|
|
|
Dear Friends,
I am new here visiting this site and this is my first question.My question is:
Print Manager should display the default paper size in paper
size listbox.
|
|
|
|
|
Is there a freeware that will help in visualizing the call flow in a C++ progrem? I have to maintain a C++ program written by another person. What are the tools that will simplify my understanding of the program?
|
|
|
|
|
Hello everyone, I hope you all can help me with my problem .
I decided to learn C++ because of it's power and because it's cross platform (I guess the typical reasons). I use Windows so that will be the platform I will be programming for until I learn enough to venture to other platforms. It seems everything related to Windows programming is going to managed .Net code. In light of this, what is the best way to learn C++ the language, not a platform or framework? As I understand from similar posts, in order to learn C++ for any platform, one must learn the language then the interested platforms/frameworks. Should I look into tools by Borland, use Visual Studio 6, or Visual Studio.Net? What books should I read? I am just generally confused on the process of learning C++ when the platform I will be programming for is making a drastic change. :P Any input on the learning process will be extremely helpful.
Lonnie
|
|
|
|
|
Generally, it does not matter what platform you work under when programming in C++ because each platform requires extensive knowledge and experience with the C++ language. Just pick a platform and learn it well. Then move to another platform. The key is to not jump around until you have mastered a platform.
Kuphryn
|
|
|
|
|
While it is true that Longhorn promotes managed code, there is backward compatibility the Win32 API. Without it, I don't think anyone would upgrade to Longhorn to see hundreds (or thousands) of dollars of legacy software not run on their new system. Also, just look on this site...there is a lot of good public domain C++/MFC code that likely won't be "ported" to managed code anytime soon. There are a lot of solidly written apps that rely on MFC which would be expensive to rewrite in managed code. So while it is true that MS is pushing the industry hard in the managed code direction, it has to overcome a tremendous amount of inertia. The history books haven't been written yet. So don't worry, start with learning the core C++ language (many good books) including standard C/C++ library and STL. The direction you take from there can be many depending on your goals (i.e Win32 API, MFC, .NET, WinFX, device drivers/Native API, COM/ATL, etc.).
|
|
|
|
|
Thanks to both of you for replying. Your answers helped a great deal. Now it's time to get busy. But one thing though. In light of the fact unmanaged code isn't going anywhere anytime soon and it's the language that counts, does it really matter what version of Visual Studio I use to learn or program in C++? I have Visual Studio 6 Pro and would rather invest in books and learning material than another IDE. Besides, all the books I've looked at for C++, the language not MS Visual C++, have never said anything about what tools or compiler to use and that confused me too.
Lonnie
|
|
|
|
|
Many introductory C++ programming books try to stay platform/compiler independent. So you are left figuring out your IDE on your own. Or worse yet, if you don't have an IDE then you will have to figure out how to build on the command line...ouch! Okay, I admit I tinker around with gcc but only for fun of it.;P
I use VS .NET Pro 2003. Whether you use the .NET framework or not, in my opinion, this is a major improvement over the VC 6.0 for several reasons. Its compliance with the ISO/ANSI C++ Standard is just shy of 100%. Improved Intellisense. Improved debugger. Improved class browser (includes base classes, marcros, message maps). Improved IDE. More stable. MFC 7.0 is improvement over 6.0. Probably other reasons I can't think of right now.
VC 6.0 is fine for learning the language, though. If you were going to buy one thing, I highly recommend Visual Assist from Whole Tomato (www.wholetomato.com). It's worth its weight in gold. You can still get the VC 6.0 version.
|
|
|
|
|
hi guys
Im doing an apllicaton in Visual C++. Totally new at it. I need to retrieve information from the database to populate the combo boxes. How do I go about doing it?? Im using a ODBC connection and Microsoft Acess. I dont know what other information i have to provide.
Hope you can help me on this.. =)
|
|
|
|
|
If you are completely new to database programming with Visual C++ and MFC, I suggest you start a reading tour from the MSDN Library.
Here is a link to the index file: click me[^].
In bottom, database programming consists of three parts: first, opening a connection to a data source. Two, executing one or more queries on the source and handling the resulted rows. Lastly, closing up and cleaning.
Knowledge of structured query language (SQL) is very useful, because for example Access is capable of responding to SQL queries.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hi!
Im writing an application using visual c++. I need t set up the DSN dynamically... how do i go about doing it? im using Access and ODBC connection... How do i go about doing that???
any help is greatly appreciated! =)
|
|
|
|