|
the problem remains.
but its strange that when i use named union line bellow:
typedef struct _bit_struct{
unsigned int sync:16;
unsigned resv:3;
union id{
unsigned network_id:13;
unsigned map_id:13;
}bit_struct;
then, i write the union value like this:
bit_struct st;
st.id::network_id=**;
all will be ok. I am puzzled.
|
|
|
|
|
Hi All,
I'm porting my neat little C++ application written in win32/minGW to MSVC9/MFC. My old WindowProcedure function for message handling compiles, but doesn't actually work anymore at runtime. So I am learning how to handle events the MFC way.
I've declared a function in my dialog application's class declaration like so:
afx_msg LRESULT OnMyUserMessage(WPARAM wParam, LPARAM lParam);
But as soon as I add
ON_MESSAGE( WM_USER+1, OnMyUserMessage)
to the message map in my cpp file, I get the following linker error:
error LNK2001: unresolved external symbol "protected: long __thiscall CMyAppDlg::OnMyUserMessage(unsigned int,long)" (?OnMyUserMessage@CMyAppDlg@@IAEJIJ@Z)
Been scouring the boards now and a lot of people have had problems with casting but I can't find any instances of this. MSDN page says for ON_MESSAGE you need to include the afxmsg_.h header: did this and no change.
The mingw linker and I had just become friends! Any suggestions as to how to resolve this?
|
|
|
|
|
I think you should define your specified MSG like:
in your UsrMsg.h or .h file anywhere
<br />
#define UM_MY_MSG WM_USER + 10
secondly, use ::SendMessage to consume the message:
::SendMessage(pWnd->GetSafeHwnd(), UM_MY_MSG, NULL, NULL); //Let's assume pWnd is a CMyDialog instance
thirdly in CMyDialog to map the UM_MY_MSG message
BEGIN_MESSAGE_MAP(CMyDialog , CDialog)
<font color="blue">ON_MESSAGE(UM_MY_MSG, OnDealMsg)</font>
END_MESSAGE_MAP
forthly implement the OnDealMsg method! Hope it helps!
modified on Tuesday, August 5, 2008 10:15 PM
|
|
|
|
|
The OnMyUserMessage() method has to exist for the link to succeed.
You should also base your messages on WM_APP (or a registered window message)
instead of WM_USER to prevent conflicts with window messages used by MFC.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks guys, I'm back up and running now thanks to your suggestions. Mark's hint to change the message to WM_APP seemed to do the trick!
|
|
|
|
|
How do I alter the mfc image icon - (on the top left corner of all programs)
I have tried to do this in the resource - icon - idr_mainframe section
but nothing is implemented when I modify the image
Thanks
Simon
|
|
|
|
|
After the window is created, you can use something like
hIcon = AfxGetApp()->LoadIcon(IDI_ICON1);
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
hIcon = ::LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
::SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
::SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Keep in mind that an Icon resource can contain multiple images in many sizes and color depths. The operating system attempts to load the best icon for the situation. In your case, you may have edited the 32x32 icon but not the 16x16 icon used for the upper left corner.
|
|
|
|
|
Hello,
I am writing a program about using the CSliderCtrl (vc provided) to control the ruler.
There is also a scroll bar for the ruler. (Sometimes the ruler length may be too long)
All I want is when I dragging the slider, the interval between two meter unit of the ruler will be changed automatically.
The ruler I used is this : http://www.codeproject.com/KB/miscctrl/uhrulerctrl.aspx
Now the interval between two meter unit would be changed when I dragged the slider.
But there's another problem. The problem is the ruler will jump to the start meter of the ruler automatically. (The scrollbar is activated)
I want the ruler can keep the original position when I dragged the slider.
(The ruler can keep the original position by a scrollbar in the demo project)
I tried some methods but the ruler always jump to the start meter...
Can someone help me to solve this question ?
Below is my part code :
void CtrlRulerDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)<br />
{ <br />
SCROLLINFO si;<br />
m_ScrollBar.GetScrollInfo( &si , SIF_ALL );<br />
INT iScrollPos = si.nPos;<br />
int i = 0;<br />
<br />
switch( nSBCode ) {<br />
case TB_PAGEDOWN:<br />
si.nPos += 5;<br />
i = m_Slider.GetPos();<br />
break;<br />
case TB_PAGEUP:<br />
si.nPos -= 5;<br />
i = m_Slider.GetPos();<br />
break;<br />
case TB_THUMBTRACK:<br />
i = m_Slider.GetPos();<br />
si.nPos = i*10;<br />
break;<br />
};<br />
<br />
si.fMask = SIF_POS;<br />
<br />
if( iScrollPos != si.nPos )<br />
{<br />
m_ScrollBar.SetScrollInfo( &si );<br />
UpdateData();<br />
m_HRuler.SetMilimeterPixel(i); <br />
m_HRuler.SetScrollPos( m_nScrolPos ); <br />
m_HRuler.Invalidate(); <br />
}<br />
<br />
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);<br />
}<br />
My Environment is : Windows Vista SP1, VS 2005 SP1, MS Platform SDK 2003 SP1
Thank you very much!
|
|
|
|
|
Hi all,
I have a static control which i converted into a hyperlink control. Whenever i needs to set focus to this control, i done it using "DrawFocusRect()". Now what should be done in order to remove that focus rectangle.
Please suggest.
By default, the color of the hyperlink is appearing black. I need to change it to blue(default) and violet (when visited).
Please suggest.
|
|
|
|
|
Typically, calling DrawFocusRect a second time with the same coordinates erases the rectangle.
What version of Visual C++ are you using? 2003 and later have a hyperlink control (CLinkCtrl) that is not very well documented until VS2008, but still usable. If you want to use it, it is a little tricky to set up since there is no item in the toolbox for it, but if you drop a custom control on the dialog and set the window class to "SysLink" and give it a non IDC_STATIC ID, all the goodies for it come alive and you can add event handlers, etc. It will do all the visited, focused, etc. on its own.
|
|
|
|
|
I am using VS2003 but i did'nt use CLinkCtrl. I created a seperate class which converts the static text to hyperlink control.
|
|
|
|
|
I use ado _RecordsetPtr to get an item from oracle database using GetValue()to read a field named Source which is of varchar2(10) datatype.
variant_t vtSource = rst->Fields->GetItem("SOURCE")->GetValue();
Can anyone show me sample code on how to convert vtSource which is of variant_t data type to char* or char array or const char* or CString data type?
|
|
|
|
|
yklim wrote: variant_t vtSource = rst->Fields->GetItem("SOURCE")->GetValue();
if you meant _variant_t then take a look at _bstr_t
led mike
|
|
|
|
|
CString has an overloaded = operator for VARIANT type so long as the variant is filled with BSTR data (ie what you would get from ADO) so you could do this:
VARIANT vt;<br />
CString str; <br />
<br />
<br />
str=vt;<br />
|
|
|
|
|
|
Does this make sense?
When I enable breakpoints, the code at the breakpoints gets executed and things appear to work as expected.
When I DON’T ENABLE breakpoints, the code at the breakpoints DOES NOT get executed.
It doesn’t make sense that enabling/disabling breakpoints would control if a piece of code is reached or not.
I'm debugging an MFC app I created in VS2005. I am running the DEBUG version and attaching to the process.
When I disable the breakpoints, nothing happens (I have used message boxes/print statements in place of breaks to see if code reached.)
|
|
|
|
|
john john mackey wrote: I have used message boxes/print statements in place of breaks to see if code reached
It could be possible that message boxes are unable to be created. Why don't you instead try using OutputDebugString() ? Are you sure this is not a problem with Debug/Release builds?
Waldermort
|
|
|
|
|
Is there any way to hide a process (not window) from the windows task manager?
Nice Guyz go to heaven, Bad guyz go wherever they want.
|
|
|
|
|
Why would you want to do something like that? One suspects for evil purposes...
Steve
|
|
|
|
|
|
No because maybe you can to hide it of Task Manager but other programs can to see it.
|
|
|
|
|
I just jumped into this project, for years the rule was "never delete a line of code". You can imagine the mess and how hard it can be to find the "right" function actually called for a task.
Does anyone know of a tool that will list me all classes, members, functions, struct, etc... that are NOT called or used by anyone else? Something like a linker option perhaps? Project is compiled under Visual Studio 2003.
I tried a few code mapping tools, but with 600K+ lines of code, thousands of classes and fucntions in hundreds of libraries, I need a black-list not a withe-list to compare too.
Thanks,
AFN
|
|
|
|
|
You could try using Visual Assist from www.wholetomato.com
Waldermort
|
|
|
|
|
Is there any API from which i can get the name of Service under which an executable is running .Pls help me.
Thanx
Sunit
never say die
|
|
|
|