|
Please help me with painting the region which I've shown on the image! I've got my own CTabCtrl class and I've tried overiding the OnPaint, OnNcPaint and OnEraseBkgnd, but none of them seem to do what I want. Do I have to implement a complete ownerdraw CTabCtrl class or can I just paint that background in some other way? Please HELP!!!
click here to see the image
Dennis
MCP, MCSD
|
|
|
|
|
How do I get the contents of CString m_strData into BYTE* m_pData?
I have a edit box that has a member variable of m_strData, and I need to get the string into the m_pData variable.
Thanks
|
|
|
|
|
try this one:
CString strTemp = "Hello World";
BYTE* pByte = (BYTE*) (LPCTSTR) strTemp;
MS
|
|
|
|
|
NO!!! This is dangerous!
You need to do this:
CString strTemp = "Hello World";
BYTE* pByte = (BYTE*) strTemp.LockBuffer();
and when pByte is not needed anymore:
strTemp.UnlockBuffer();
Never cast away the const-ness of a pointer...
Concussus surgo.
When struck I rise.
|
|
|
|
|
What Martin suggested sets m_pData to point to m_strData. I interpret your question as...You want to copy the contents of m_strData to m_pData(which is already allocated).
If so you could use memcpy
or
strcpy and cast m_pData to a char*
Gary Kirkham
A working Program is one that has only unobserved bugs
|
|
|
|
|
Yes I wanted to copy the string thats held in m_strData into m_pData.. I used his suggestion and it worked fine.. I just saw the second post and will adjust my code...
Thanks everyone!
|
|
|
|
|
I am not an experienced sockets programmer, so I think I am missing something very basic. All of this is for UDP messages only.
I have a program that has two sockets set up. 1 for sending, and one for listening.
The sender is created by using the INADDR_ANY IP, and a specific port number (1594).
The listener is created by using the INADDR_ANY IP, and 0 as the port number.
This has been working for years with no problems.
I recently had to add the ability to send a broadcast UDP packet, but with a specific source address (the default would have picked the primary NIC source address, and this was causing problems).
Sending broadcasts is not the problem. This has been working for years also. It was the part where the source IP needs to be specified where problems came in.
I created another socket that uses a specific IP (10.3.2.1) as the IP, and 0 for the port number (letting a port get picked automatically). I send the message, then close the socket.
The message gets sent correctly, and a response does come back (using a sniffer to see this).
The problem is that my listener socket does not see the reply.
Since the only addition to the otherwise working application was the new (temporary) socket to send the broadcast, I'm wondering why this reply is not seen by the listener socket?
I'm hoping someone will be able to see a basic flaw in my thinking.
Thanks.
|
|
|
|
|
Anonymous wrote:
The problem is that my listener socket does not see the reply.
Do you really try to recieve from the right interface? Have you called bind to bind the listening socket to the interface the data is really coming in on, or are you just listening on the "default" interface?
|
|
|
|
|
The bind for the listening socket is passed the ANY_ADDR, and 0 for the port number. When I do a recvfrom on this type of bind, does this rcv everything, or only messages that haven't been directed to other more specific binds?
Thanks again.
|
|
|
|
|
I'm a little confused following your story and I am no expert either but I have written some small apps in VB to send and receive UDP datagrams. You must be using some sort of user defined 2-way UDP communication cause I don't know what you meant about a reply.
Anonymous wrote:
The listener is created by using the INADDR_ANY IP, and 0 as the port number.
Doesn't the listening port number have to be the same as the transmit port?
In my apps, one box sends UDP broadcast using port XYZ, my other app listens using port XYZ. Of course they both have to be on the same subnet. I tried before using different subnets and it wouldn't work.
|
|
|
|
|
The listener needs to catch messages comming from multiple ports, and this part has been working for quite a while.
The architecture is not standard, and this is probably confusing. The sender, and the listener are in separate threads, and don't really interact with eachother.
I guess than main question is:
What happens when you bind a socket to INADDR_ANY, and port 0 (meaning all ports), and when you have another socket bound to 10.3.2.1, and port 0?
In this case does the first socket still rcv messages sent to 10.3.2.1, or are they going to be directed to the second socket, since it is more specific? To confuse things even more, what happens when I close the second socket? It looks like any messages will get returned a Destination Port Unreachable error message (ICMP).
Thanks for your reply.
|
|
|
|
|
I'm working in an ActiveX and I'm trying to load a Menú using CMenu.LoadMenu.
The problem is that AfxGetResouceHandle returns NULL and I have no idea why. Can anyone help me ??
|
|
|
|
|
I have solved the problem, I add this line
AFX_MANAGE_STATE(AfxGetStaticModuleState())
|
|
|
|
|
Two things:
1.At design time, how do I make certain toolbar buttons invisible (I dont want to delete them in case I need them later)
2. How do I dynamically make a toolabr buton invisible at runtime? What code do I need. I tried:
void CFormViewMDIView::OnToolbarup()
{
GetDlgItem(ID_TOOLBARDOWN)->ShowWindow(SW_HIDE);
}
but it crashed.
Thanks for the help,
ns
|
|
|
|
|
First, check this FAQ
Then, try this (I´ve already posted that once, but i am still not sure it works)
Create a CtoolbarCtrl object, assign it the return value of pBar->GetToolbarCtrl where pBar is a *Ctoolbar . Then you have access to the EnableButton() and other functions of the same kind using the CtoolbarCtrl .
Just tell me if it works ...
~RaGE();
|
|
|
|
|
m_pToolBar->GetToolBarCtrl().HideButton(ID_TOOLBARDOWN, TRUE);
Where m_pToolBar is a pointer to a CToolBar object, and ID_TOOLBARDOWN is the ID of the button you wish to hide.
--------
PMGRE --Shog9 --
|
|
|
|
|
Thank you. I'll try it. Much appreciation,
ns
|
|
|
|
|
It compiles fine, but crashes when I press the button that executes this snippet:
void CTrain1View::OnToolbarup()
{
//AfxMessageBox("Up pressed");
CToolBar * m_pToolBar;
m_pToolBar = (CToolBar*)GetDlgItem(IDR_MAINFRAME);
m_pToolBar->GetToolBarCtrl().HideButton(ID_TOOLBARDOWN, TRUE);
What am I doing wrong?
Error is memory couldnt be read...
|
|
|
|
|
The toolbar is *not* a child of the view, so the line
m_pToolBar = (CToolBar*)GetDlgItem(IDR_MAINFRAME); isn't going to work. If you used the app wizard to start your program, the CMainFrame class will have a member m_wndToolBar that is the toolbar. You can create an access method for this, or just put your code in CMainFrame to start with (if it's only purpose is doing stuff to toolbars, it probably belongs there anyway).
--------
PMGRE --Shog9 --
|
|
|
|
|
WHat are the special things to be done to make the toolabr button and a corresponding menu item both run the same code? Would one give the same ID to both the button and the menu item? Is that legal?
Thanks,
ns
|
|
|
|
|
ns wrote:
Would one give the same ID to both the button and the menu item?
Yes.
ns wrote:
Is that legal?
Yes.
--------
PMGRE --Shog9 --
|
|
|
|
|
That worked. I tried making a getToolbar() public method in mainframe returning the toolbar object created in CMAinFrame, but it said no copy constructot available. SO I'll put my code in the frame class, though theres data involved that I'm not sure the frame needs to know about...
Thanks a million,
ns
|
|
|
|
|
I have a 3rd party library that shipped with only the DLL itelf and a header file with function prototypes and constants. All the procedures inside the DLL are declared using the dllimport keyword. Does this mean that I can't dynamically link into this DLL at runtime because none of the functions were exported? I've already written an app that links to this DLL statically, and that works fine, but I'd rather use dynamic linking.
Everything I've read so far points me to the fact that since there isn't a .DEF file, and the functions aren't declared using dllexport, I can't dynamically link to this library. Am I right?
Thanks guys...
-Mike Zinni
email: mzinni@rimail.com
AIM: zin9999
|
|
|
|
|
Do you have a lib file? You should be able to link with it.
Best regards,
Alexandru Savescu
|
|
|
|
|
Yes. I have the .LIB file and the directory is included in my Tools->Options->Directories->Library files settings. I wrote the following code to link to the DLL.
typedef int (CALLBACK* LPOMNICREATEFUNC)(void);
BOOL COmniDoc::LoadOmniLibrary()
{
m_bOmniLoaded = FALSE;
m_hOmniLibrary = LoadLibrary("SD2.dll");
if(m_hOmniLibrary)
{
m_bOmniLoaded = TRUE;
m_lpfnSD_Create = (LPOMNICREATEFUNC)GetProcAddress(m_hOmniLibrary, "SD_Create");
}
return m_bOmniLoaded;
}
m_lpfnSD_Create is of type LPOMNICREATEFUNC.
LoadLibrary returns a valid handle, but the m_hlpfnSD_Create variable is set to NULL after the call to GetProcAddress...
-Mike Zinni
email: mzinni@rimail.com
AIM: zin9999
|
|
|
|