|
Also, if the GetItem implementation is in a C file do not forget the extern "C" stuff:
extern "C"
{
#include "Header_in_C_That_Contains_GetItem.h"
}
Best regards,
Alexandru Savescu
|
|
|
|
|
Hello,
I've searched the MSDN to no avail...
I've created a CSlider control on a DialogBar and am constantly getting an assertion error (hWnd is not valid) when I try to set the range (CSliderCtrl::SetRange(0, 50, FALSE)). It's as though I'm trying to set it before the slider control window is 'valid' (or created?), however, the error occurs after I see the slider physically on my DialogBar, so I know it exists at the time I try to SetRange().
If I 'ignore' the first assertion error, all subsequent executions work fine.
At what time in the code execution (standard wizard or MFC methods) may I set the slider control's parameters without error? Or does anyone know what is going wrong with this scenario? I really want to learn. Thanks!
JennyP
|
|
|
|
|
The easiest thing to do would be to put a check on the slider's hWnd member:
if( m_SliderCtrl.m_hWnd == NULL )
{
m_SliderCtrl.SetRange(...);
}
That'll stop it asserting.
You need to make sure that the OnInitDialog member has been called first (by the framework, that is, don't call it yourself.)
I've also found that doing an UpdateData( FALSE ); call before you first access the control makes sure that the control variable is actually initialised properly
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
Thanks for the reply. I ended up calling UpdateData(FALSE) in the CMainFrame just after this dialog bar is created (and initializing other aspects such as ticks, range, etc.). It doesn't feel very like good OOD, but it's the one sure place that I can consistently initialize my DialogBar controls.
Also, I assume in the code fragment you wrote, you meant to write a != NULL instead of a == NULL?
Thanks!
JennyP
|
|
|
|
|
JennyP wrote:
Also, I assume in the code fragment you wrote, you meant to write a != NULL instead of a == NULL?
Yeah, sorry
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
I would like to see all the ICMP messages coming to my machine. I wrote the following code but I can not read anything from the socket. Where is my mistake ?
SOCKET hSocket = ::socket(PF_INET, SOCK_RAW, IPPROTO_ICMP);
while (true)
{
sockaddr_in from;
int nFromlen = sizeof(from);
int nRead = recvfrom(hSocket,pRecvBuf,1024,0,(sockaddr*)&from,&nFromlen);
}
When I ping another machine from dos prompt I expect to catch something but nothing happens and recvfrom blocks. I have admin privileges. Can someone help me on this subject please. I could not solve it.
Thank you
Orcun Colak
|
|
|
|
|
Dear All,
is there any way to develop plugin for IExplorer. if yes then plz
if some one of you can reffer me to the materail for this help.
any code examples or any tutorial on the net.
waiting for reply.
omar lodhi
|
|
|
|
|
is there a way i could disable the menus from my code
the code in msdn(july 2002) gives me a runtime exception.
thanks
looking forward from all the gurus of code
|
|
|
|
|
*ahem*
we are projects of code here... or something like that.
Anyway, could you give a few more details? Are you using MFC, or straight Win32? Do you need to disable one menu, or all of them, or just certain ones? And what have you tried (i don't have the july MSDN here)?
For reference, the functions EnableMenuItem() and potentially DrawMenuBar() will most likely be your starting point.
Shog9
--
Maybe Java is kind of like God, it "works in mysterious ways". It seems like your apps are running slowly, because in the backgroud Java is solving world hunger, or finding the cure to cancer.
- Ryan Johnston, Don't die java!
|
|
|
|
|
i have tried using
pMenu->AppendMenu(MF_STRING | MF_DISABLED, 0, "Insert");
and
the submenu pointer code
CMenu* mmenu = GetMenu();
CMenu* submenu = mmenu->GetSubMenu(4);
if (menuID == IDM_VIEW_OBJECTONLY) {
submenu->CheckMenuItem(IDM_VIEW_OBJECTONLY, MF_CHECKED | MF_BYCOMMAND);
submenu->CheckMenuItem(IDM_VIEW_PATHOBJECT,
and some thing from msdn .. which was more simpler
but all things give me one same run time error..
looking forward from all the gurus of code
|
|
|
|
|
SilentWarrior wrote:
but all things give me one same run time error
What run time error is that?
The code looks right (though cut off); if i were to guess, i'd say maybe 4 is the wrong indice for the menu you're looking for. Step through with a debugger & see what the return values are for each stage.
Shog9
--
Maybe Java is kind of like God, it "works in mysterious ways". It seems like your apps are running slowly, because in the backgroud Java is solving world hunger, or finding the cure to cancer.
- Ryan Johnston, Don't die java!
|
|
|
|
|
hi,
I'm trying to gain access to a 16-bit app.
i'm trying something like :
::readProcessMemory(ProcHandle, (LPVOID)OffSet, buffer, BytesToRead, &BytesRead);
this doesn't work.
I did some research and it seems that all 16-bit apps operate in the same address space.
Well, ... I found a DLL (toolhelp.dll) with which I can get the Job done but only in WIN9x.
I need something to get the job done under NT too.
preferably I'm looking for a way that works equally good in all environments.
thx & greetz
I used to have a life ... now I have a computer
|
|
|
|
|
Help,
I'm trying to launch a new IE instance from a CHtmlView based SDI application.
The code is as follows:
CWinApp* pApp = AfxGetApp();
CDocTemplate* pDocTemplate;
POSITION pos = pApp->GetFirstDocTemplatePosition();
pDocTemplate = pApp->GetNextDocTemplate(pos);
CDocument* pDoc = pDocTemplate->CreateNewDocument();
CFrameWnd* pNewFrame = pDocTemplate->CreateNewFrame(pDoc/ *GetDocument()* /,
NULL/ *(CFrameWnd*)AfxGetMainWnd()* /);
pDocTemplate->InitialUpdateFrame(pNewFrame, NULL);
CPeachPlorerView* pView = (CPeachPlorerView*)pNewFrame->GetActiveView();
pView->SetRegisterAsBrowser(TRUE);
*ppDisp = pView->GetApplication();
Unfortunately the new frame is parented to the previous one. I think the CDocTemplate framework inherit the same CWinApp. So when I close the parent the child is closed to.
The best way would be to launch a new instance of my application, and keep a handle on it so that I can pass the IDispatch interface (ppDisp). I mean initializing the SDI from another. I've no idea on how to do this. Can somebody help me ?
Yarp
|
|
|
|
|
What is the Win32 API equivalent of MFC's ModifyStyle ?
rechi
|
|
|
|
|
LONG lStylesRemove;
LONG lStylesAdd;
LONG lStyle = ::GetWindowLong(hWnd, <FLAGS>);
lStyle &= ~lStylesRemove;
lStyle |= lStylesAdd;
::SetWindowLong(hWnd, lStyle);
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
OK, .
What about ModifyStyleEx ? I had problems once trying the way you wrote above.
rechi
|
|
|
|
|
First off I made a mistake in the way that I called GetWindowLong. It should be called like this
::GetWindowLong(hWnd, GWL_STYLE);
and SetWindowLong like this:
::SetWindowLong(hWnd, GWL_STYLE, lStyle);
As far as the Ex styles, it should work exactly the same except that you will use the GWL_EXSTYLE flag instead.
THere is however one thing that I just thought of, if you are modifying a style that deals with the window frame, you will need to make a call to SetWindowPos in order to force the window to incorporate the new style changes into your window.
I found the code directly out of the ModifySTyle function in MFC, here is how they do it.
ASSERT(hWnd != NULL);
DWORD dwStyle = ::GetWindowLong(hWnd, nStyleOffset);
DWORD dwNewStyle = (dwStyle & ~dwRemove) | dwAdd;
if (dwStyle == dwNewStyle)
return FALSE;
::SetWindowLong(hWnd, nStyleOffset, dwNewStyle);
if (nFlags != 0)
{
::SetWindowPos(hWnd, NULL, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | nFlags);
}
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I loaded a project I brought in from home into VS at work and it says classview info isnt accessible so classsview pane is unpopulated. Its not read only or anything...
Help! I need the class info.
|
|
|
|
|
just delete the .clw ,.aps,.npc from your workspace folder and open the workpace agin that will work.
Renjith-CPian.
|
|
|
|
|
Thanks so much! This problem has been so pesky! Appreciate it,
ns
|
|
|
|
|
I'm making a standard MFC app with one dialog. On the dialog I have placed 2 radio buttons. When I run my program none of the radio buttons is checked. How do I make one of the default checked when I start my program?
|
|
|
|
|
Do you have a member variable set up to handle the radio buttons (through ClassWizard)? If so, in your constructor, set it to 0 or 1 in the class constructor (depending on which radio button you want checked.)
If not, you need to set up control classes for each radio button, and in the OnInitDialog function, call:
yourButtonObject.SetCheck(1);
for the button you want to have checked.
Even if you win the rat race, you're still a rat.
|
|
|
|
|
make a contol variable and control variable.SetCheck(1);
Renjith-CPian.
|
|
|
|
|
Hello all,
I would like to simulate the mouse clicking and selecting commands. Basically, if I press a button in a toolbar, I want it's function to run. For instance the "New" button, or the "Open" button in the Word toolbar, will obviously create a new file, or open a selected a file.
What I would like to do, is know how to send a message saying "I clicked on a Toolbar button!" to the project.
I'd also like to know ho to do this from the DropDown Menu. I'd liek to be able to say I selected a Drop Down Menu command without doing any of the selecting the command from the drop down menu (call me lazy, hehehhehhe).
If anybody knows how to do this, that'd be cool if they could show me how or show me where I could learn,
Thanks a bunch
|
|
|
|
|
Greetings...
I have custom draw treeview control. I am able to change the default color of the treeview by using the following code :
case NM_CUSTOMDRAW :
case CDDS_CUSTOMDRAW:
return CDDS_ITEMPAINT:
case CDDS_ITEMPAINT:
/*
changing the color of the text here
*/
How can I trap the drawing of the checkbox so that i can chage the color in which the check box is drawn ?
Please help...
Ritesh
|
|
|
|