|
I know others that have mentioned this behavior when opening a project with many files. The VS editor is just not built to handle such a big payload.
|
|
|
|
|
I have a DLL written in VB6(not sure) and need to use it from C++
I created manually .DEF file with names of all DLL functions and generated .LIB
(with LIB /DEF:MyDLL.DEF command)
But C++ adds name decoration if I declare imported function as stdcall,
so there are linker errors
e.g. MyFunc in DLL -> _MyFunc@16 in VC++
How to make it work?
|
|
|
|
|
Wrap the declarations with extern "C"
|
|
|
|
|
no way!
It forces the compiler to generate prolog/epilog code for C calling convention (caller adjusts stack pointer). It corrupts stack in my case becouse calling function uses __stdcall convention (callee adjusts stack before return from function)
|
|
|
|
|
I made an application with MFC, Doc/View architecture and MDI type. Now the users say that it is too hard to understand and they confuse with more documents. Is there a simple way to transform the program in an SDI type ? Or better, is there a way to limit the maximum number of ducuments ? (So I can keep the MDI for expert users).
Thanks.
|
|
|
|
|
You should be able to limit the open/new options by checking how many documents of your doc/view are already open.
In the ON_COMMAND_UI update handler for ID_FILE_NEW and ID_FILE_OPEN you should disable the option if the registered CDocTemplate object for that doc/view type has any open documents:
POSITION pos = pDocTemplate->GetFirstDocPosition();
pCmdUI->Enable(pos == NULL);
Depending on where you disable the commands, you may need to mod how you get the pointer to the CDocTemplate object.
Maybe:
POSITION pos = AfxGetApp()->m_pDocManager->GetFirstDocTemplatePosition();
CDocTemplate *pTemplate = AfxGetApp()->m_pDocManager->GetNextDocTemplate(pos);
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
Hi,
I need to write a litle kernel-mode code. I want to see what the following code will do in kernel mode.
<code>
.
.
.
return *((int *) 0);
</code>
Can I write a kernel mode code by using Visual Studio 7. (I do not have DDK)
And please make me some prediction that, what will the above code do in kernel mode.
thanx
karanba
|
|
|
|
|
|
I don't think this is kernel mode code. This is "I want to crash code"
MOV EBX,0
MOV EAX,[EBX]
RET
So, you're telling the compiler to load what's at address 0 and return it. There's nothing really important there, some compatabilty interrupt table stuff. But you'll just generate an exception, a crash, but nothing important.
To write in kernel mode, consult the DDK.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
Santa Cruz Networks
|
|
|
|
|
I am using a treeview control in an application I am writing and I am trying to come up with an efficient way to store the hierarchial data in it. I considered creating a vector of all the items which included an id of the parent item, but reconstructing the treeview when it is large would be quite inefficient this way. I haven't seen any premade classes to store treeview data, but I was hoping someone could point me to one, or give me some ideas on a good way to store this type of data.
Thanks.
|
|
|
|
|
|
You could always create a simple hierarchial recursive class to store the data... something like this (not complete):
class TreeNode : public CObject
{
protected:
CString m_cDisplayText;
int m_iIconIndex;
void *m_vpUserData;
CObList m_oChildNodes; // list of TreeNode elements
public:
TreeNode() { m_iIconIndex = 0; m_vpUserData = NULL}
TreeNode(LPCSTR cpDisplayText, int iIconIndex = 0, void *vpUserData = NULL)
{ m_cDisplayText = cpDisplayText;
m_iIconIndex = iIconIndex;
m_vpUserData = vpUserData;
}
~TreeNode()
{ TreeNode *pNode;
POSITION pPos = m_oChildNodes.GetHeadPosition();
while (pPos)
{
pNode = (TreeNode *)m_oChildNodes.GetNext(pPos);
if (pNode)
delete pNode;
}
}
// std accessors....
LPCSTR GetDisplayText()
{ return (LPCSTR)m_cDisplayText; }
void SetDisplayText(LPCSTR cpDisplayText)
{ m_cDisplayText = cpDisplayText; }
void *GetUserDataPtr() { return m_vpUserData; }
void SetUserDataPtr(void *vpUserData)
{ m_vpUserData = vpUserData; }
CObList *GetChildNodes() { return &m_oChildNodes; }
virtual void Serialize(CArchive &ar)
{
if (ar.IsStoring())
{
ar << m_cDisplayText << (DWORD)m_iIconIndex;
}
else
{
ar >> m_cDisplayText >> (DWORD&)m_iIconIndex;
}
m_oChildNodes.Serialize(ar);
}
};
|
|
|
|
|
As I want to display a JPEG file like the one using PictureBox class, is there any class has the same use in Visual C++ ?
thx
|
|
|
|
|
|
I have seen this before, but I'm using dialog base and as a beginner of VC++, I don't know how to change the idea from DOC base to Dialog base.
pls help
|
|
|
|
|
I'm creating a ocx in VC which is used for a custom protocol. The main handshaking and connecting to remote host etc., will be handled by a VB app.
I only have to read the COM port through my local buffer variable which is set by VB app in OnComm event.
If my input buffer is empty, I need to wait till I get something in my buffer? Can someone pls. help me how I can do that wihtout jamming the application.
Thanks in advance,
|
|
|
|
|
Simple example is using thread function which wait to fill the buffer and after it send some flag to your application (Get/Set or Fire - are your choice).
|
|
|
|
|
Or, you could use overlapped I/O on the read, triggering a callback function when the read actually occurs (or posting to an I/O Completion Port).
|
|
|
|
|
Hi,
I tried that with WaitForSingleObject(), but it hangs up the whole thread for certain time and gives timeout messages.
As far as I know, Visual Basic run all components in single thread, correct me if I'm wrong.
I can't use callback functions, as this code model doesn't integrate with the existing system, which uses some other protocols. For your clarification - I'm working on ZModem, developing VC++ OCX which will be used in VB and Powerbuilder applications.
|
|
|
|
|
Hi,
I my application(MFC dialog based),initially i have to put the focus on specified button control.
i.e.Suppose my dialog having Three buttons 1.OK,2,Cancel,3.Button1.Initially i have to put focus on Button1, if user clicked Enter key the Button1 message handler will call.
for this i tried like this.
1.CMyTestDlg::OnInitDialog()
{
GetDlgItem(IDC_BUTTON1)->SetFocus();
return FALSE;//Instead of TRUE
}
It showing correctly focus on Button1,But if i pressed enter key OnOK() is calling.
Please help me inthis context.
regards
anju
anju
|
|
|
|
|
Hi,
You don't have to setfocus() on OnInitDialog(), Try this one --
In design mode , go to Layout, choose Tab order,
Click on the buttons that you want the tab order sequence.
Run the application,
-- Press Enter when the dialog shows up
hope this might help you out
|
|
|
|
|
Hi SNathani,
Thank you for your suggestion.
Suppose, if my button is OwnerDrawn, what can i do?
regards
anju
|
|
|
|
|
It does not make any difference if the button is OwnerDrawn. You main problem will probably be that the OK button is set as the default button in the resource editor, you may need to clear this flag to get RETURN to act correctly on BUTTON1.
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
Hi Roger Allen,
Thanks for your reply.
Already I cleared Ok button "default button" property.
can you guess other thing.
regards,
anju
|
|
|
|
|
Rather than calling SetFocus(), you should call the following:
GotoDlgCtrl(GetDlgItem(IDC_BUTTON1));
|
|
|
|