|
Ok. This is different from most questions about "what is my ip address". Some background: I'm developing an application that will record data UDP broadcast or multicast from a standalone device.
Technicians will take their laptops with them when on travel from their home/office and plug it into this device's network port with a crossover cable (private LAN) to facilitate recording of data. The device can be assigned a private IP address but I don't think this is the best choice since this would require the technician to modify his existing IP address, etc. in Windows, and cause headaches when he goes back to the office. This is just an example. In some situations some technicians and others will want to record data from their desktop PCs if the data is local to their facility. Thus, I would not know their local IP addresses at these types of facilities.
I would like to program the device to reply to a message broadcast from my application (laptop) and set it's ip address accordingly. Since, the laptop and standalone device could be on two different subnets (or even nets, I think) though physically hooked up, I think I would have to send a broadcast IP message telling this device what my IP address is so that he can set his address to one within the same subnet/net, right? Or, a second option would be to pick a pre-defined IP address for the device and have my application on the laptop send it a message with it's source IP address in the IP header and have the device dynamically change it's IP address to the same subnet/net.
The device is a UNIX flavored RTOS type. I think POSIX. Don't know if there is a way to dynamically change its IP address. If anyone knows a command, please let me know. BTW, we have application source code for the device that we developed.
Any comments or suggestions? This isn't totally off-topic here since I want to know what would be the best method for performing this under Windows and if there are any alternative ways. Of course, if anyone knows UNIX or POSIX that's helpful too.
|
|
|
|
|
I would like to program the device to reply to a message broadcast from my application (laptop) and set it's ip address accordingly.
This is essentially what DHCP or BOOTP does. Install a DHCP server on the laptop, and configure the device to get its net address by DHCP.
|
|
|
|
|
Thanks for the reply. You're right that would probably be the easiest thing to do but setting up a DHCP server on every laptop wouldn't be that easy.
|
|
|
|
|
I am trying to create a simple dialog box with scrolling horizontal text (marquee) in Visual C++. I feel like I've seen a really easy method somewhere but can't remember. Any help would be appreciated
Thank you
|
|
|
|
|
there isnt any easy function in mfc or c++ to do that but its not too hard to scroll text across a static control on a timer interval
there are a number of classes here to do that ... they might be useful if you decide to write your own
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" sonork: 100.18128 8028finder.com
|
|
|
|
|
Scrolling text my forte:
Many ways to skin a cat.
Using TextOut and SetBoundsRect and select clipping regions give optimal scrolling.
Also you can use ScrollWindow and paint the bits uncovered.
Normski. - Professional Windows Programmer
|
|
|
|
|
For sorting a listcontrol on header-click, I use the following code:
But the condition if (iIndex1 == iIndex2) in CompareItems is always true.
The callback func is always called to compare an item with the same item.
And this happens for each item in the list....
Anyone already seen this behaviour? Any solve for this ?
Greetings,
Niko
//Sorting
static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
if(!lParamSort) return 0;
CListCtrlEx* pListCtrl = (CListCtrlEx*) lParamSort;
ASSERT_VALID(pListCtrl);
return pListCtrl->CompareItems( lParam1, lParam2);
}
void CListCtrlEx::SortOnCol(int iCol)
{
if(m_iSelColumn == iCol)
m_iSortDirection = -m_iSortDirection;
else
{
m_iSelColumn = iCol;
m_iSortDirection = 1;
}
//Set callback
SortItems( CompareFunc, (DWORD)this );
//Show first Item
int iItem = GetNextItem(-1, LVNI_SELECTED);
if (iItem > 0)
EnsureVisible(iItem,true);
}
int CListCtrlEx::CompareItems(int iIndex1, int iIndex2)
{
const int iMaxSortCol = 100;
char szBuf1[iMaxSortCol]; memset(szBuf1,0x00,sizeof(szBuf1));
char szBuf2[iMaxSortCol]; memset(szBuf2,0x00,sizeof(szBuf2));
if (iIndex1 == iIndex2)
return 0; //Shouldn't be possible
LV_FINDINFO FI;
FI.flags = LVFI_PARAM;
FI.lParam = iIndex1;
iIndex1 = FindItem( &FI);
if(iIndex1<0)
return 0;
GetItemText( iIndex1, m_iSelColumn, szBuf1, iMaxSortCol-1 );
FI.lParam = iIndex2;
iIndex2 = FindItem( &FI);
if(iIndex2<0)
return 0;
GetItemText( iIndex2, m_iSelColumn, szBuf2, iMaxSortCol-1 );
return m_iSortDirection*strcmp(szBuf1, szBuf2);
}
void CListCtrlEx::OnColumnclick(NMHDR* pNMHDR, LRESULT* pResult)
{
CWaitCursor Wait;
NM_LISTVIEW* pNM = (NM_LISTVIEW*)pNMHDR;
// TRACE("Clicked on column %d - Sorting: %s.\r\n", pNM->iSubItem, ((m_iSortDirection == m_iSortDirectionDsc)?"DSC":"ASC" ));
SortOnCol(pNM->iSubItem);
*pResult = 0;
}
|
|
|
|
|
How do you set the item data of a list item ?
We do not inherit the Earth from our ancestors. We borrow it from our children.
Antoine de Saint Exupéry (1900-1944)
|
|
|
|
|
The values you're passing into the CListCtrlEx::CompareItems() method are the item data values of the items to be compared, not their indexes (which you've obviously realised, because your code is using FindItem to search for the LPARAM - sorry for stating the obvious!). Are you sure that the item data values are set correctly and uniquely for each list item?
"We are the knights who say Ni" (The Knights Who Say Ni)
|
|
|
|
|
Thank you for your help,
That was 'obviously' the problem...
Greetings,
Niko
|
|
|
|
|
If you're after every single message, you might be interested in PreTranslateMessage() . It's called in the window that receives the message, which then calls PreTranslateMessage in its parent window, all the way up to the main frame window.
"We are the knights who say Ni" (The Knights Who Say Ni)
|
|
|
|
|
Seems to work, but not all messages.
For example, when I press Ctrl+4, or any other SysCommand, the Frame Window doesn't get any message.
What I basically want to do is monitor inter-mdichild messages (switching windows, closing a window, etc). It seems that the messages stop at the Client Window and doesn't travel up to the Frame Window.
Some other ideas
|
|
|
|
|
|
Thanks for the infos
|
|
|
|
|
|
Hello,
Still struggling with the linker. Many things have been solved, but still (at least) one left.
So, I have mylib.lib, which is written in C and I'm using it in my console program, that uses also MFC. I have the source code of that lib, but I can't change it. I use makefile for compiling and linking.
I have (among others) compile options /TP /MT, so it's C++ and multithreaded. With a linker option /NODEFAULTLIB:libc.lib, I avoid crashes with libcmt.lib.
So I compile my selfmade files and then link the .obj files and .libs and I get error LNK2001: unresolved external symbol _errno. The place where I get this error from is in one file in mylib. I checked, that it includes header errno.h.
If I remove linker option /NODEFAULTLIB:libc.lib, this error of _errno disappears, but I get lots of errors, because libc and libctm define same functions. Or if I make it single threaded, the problem is with _begingthreadex and _endthreadex.
I don't understand. Why doesn't the linker realize errno? Could it be because of messing with C and C++?
-Janetta
|
|
|
|
|
The way out of this dilemma is to have both componentes (the MFC program and the lib) compiled for the same version of the C run-time library. Go to the project settings for your MFC app and select (in the first tab) "Use MFC in a static library". Then go to the C/C++ tab, category "Code generation" and set "Use run-time library" to "Multithreaded". Good luck.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Janetta wrote:
Could it be because of messing with C and C++?
Yes it could. Try doing this:
extern "C"
{
#include "header_written_in_C_used_from_c_plus_plus"
}
This will inform the C++ compilers to use C calling conventions, not C++ ones which are by default.
Best regards,
Alexandru Savescu
|
|
|
|
|
I have a toolbar that under certain conditions i may need to diable an item.
how can this be done?
the only set function i can find is SetButtonInfo.
i tried to change the state of the toolbar button to point to an id with out a function. i noted if i do that as i am building the toolbar and did not yet attach a function to it that is shows diabled.
i tried the following
CToolBar* pBar = &m_wndToolBar;
if (pBar != NULL) {
pBar->SetButtonInfo(11,ID_NULL,TBBS_BUTTON,11);
}
this had no effect on the toolbar.
thank you for any help
|
|
|
|
|
The easiest and cleanest way to handle enabling/disabling any UI item in an MFC app is by using update handlers, which can be added with the ClassWizard.
Search in MSDN for things like the ON_UPDATE_COMMAND_UI macro and CCmdUI objects, and have a look at MFC Technical Note 021 (TN021 in the index). The automatic disabling of toolbar buttons and menu entries without command handlers is also dealt with through the same architecture, and can be disabled by setting the m_bAutoMenuEnable member of your main frame window to false. See also Mike Dunn's C++ FAQ q.7.1
"We are the knights who say Ni" (The Knights Who Say Ni)
|
|
|
|
|
I don´t know myself at all with Toolbars, but after a short read of the msdn, i think you could try the following :
Create a CToolBarCtrl object, assign it the return value of pBar->GetToolBarCtrl where pBar is your CToolBar . Then you have access to the EnableButton() and other functions of the same kind using the CToolBarCtrl .
Hope this helps...
~RaGE();
|
|
|
|
|
Hi,
I am trying to develop a Resource editor like VC++ .
It seems that the way a CDialog is displayed while running
in applications and while CDialog is shown in the Resource
Editor.
Can some tell me what is the difference.
Thanks,
San
John 3:16
For God so loved the world,
that he gave his only begotten Son ( Jesus Christ ) ,
that whosoever believeth in him should not perish, but have everlasting life.
|
|
|
|
|
I have both Visual Studio C++ 6.0 and .Net Enterprise Architect installed on an Win 2K platform. Whenever I use the 6.0 debugger it launches the .Net debugger instead. Does anyone know a work around for this bug?
Thanks in advance for your assistance.
Amos Kermisch
|
|
|
|
|
I think .NET puts itself as the default JIT debugger. But if I have a VC 6.0 project set a breakpoing somewhere in the source files and hit F5 then my project is debugged under VC 6.0
Best regards,
Alexandru Savescu
|
|
|
|
|
Alexandru,
Just wanted to thank you...your suggestion works great!
Amos
|
|
|
|