|
Hi there,
Just inherited some VC++ code from a colleague, including .cpp,.CPP,.h,.H, i know nothing about Visual C++, but I was told the program was executable.......my silly questions are:
1) .cpp and .CPP the same ?
2) How to build them into one project to make it executable using Visual Studio 2005?
I couldn't find the straightforward answer from the Internet.
Any hint? Many thanks.
Regards,
Aloha
|
|
|
|
|
Aloha2007 wrote: Just inherited some VC++ code from a colleague, including .cpp,.CPP,.h,.H,
What version of VS was s/he using?
Aloha2007 wrote: 1) .cpp and .CPP the same?
Yes.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi David,
Many thanks for reply.
He use Visual Studio 2003 or even earlier version.
The built-up project was executable in 2003 version, but when run it on 2005 version, it says: the project is out of date.
Then I asked for the original codes, but don't know how to build it on Visual Studio 2005.
Regards,
Aloha
|
|
|
|
|
You can make a project and insert your codes on that project.(Ctrl+Shift+N) after press these buttons you see a window that you can select project type select MFC then MFC Application.
|
|
|
|
|
Does MFC provide any method which will give me a list of handles or pointers to ALL open documents or MDI child windows in an MFC MDI Doc/View application?
Thanks
|
|
|
|
|
The CDocTemplate objects keep track of open documents. By iterating through the
registered templates, you can get the open docs associated with each template.
For enumerating views, you can do it the windows way(s) like EnumChildWindows()
or you could also use CDocument::GetFirstViewPosition()/CDocument::GetNextView()
to get the views for each document obtained as described above.
For an example of enumerating documents, you can check out the source code.
CWinApp::CloseAllDocuments() is an example.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Great! Using CDocTemplate::GetFirstDocPosition and CDocTemplate::GetNextDoc, along with CDocument::GetFirstViewPosition and CDocument::GetNextView, I was able to get everything I needed.
Thanks very much!
|
|
|
|
|
Hi
when i compile this:
#include <windows.h>
#include <mapiwin.h>
typedef struct _INST
{
UINT cRef;
LPMALLOC lpmalloc;
} INST, *PINST;
int main()
{
PINST pinst;
pinst = (PINST) PvGetInstanceGlobals();
return 0;
}
i get
Linking...
testmapiWin.obj : error LNK2001: unresolved external symbol _pinstX
Debug/testmapiWin.exe : fatal error LNK1120: 1 unresolved externals
pinstX is defined in MAPIwin.h
extern LPVOID pinstX;
dose any one have a idea why this won't compile...
Many Thanks
Calvin
|
|
|
|
|
Try adding this to your source code, in some *.cpp file
#pragma comment(lib,"mapi32.lib")
|
|
|
|
|
thanks
I tried that and stil got the same error
is this the same as adding mapi32.lib to the linker "additional dependancies" as i all ready have it added there.
Many Thanks
Calvin
|
|
|
|
|
Ok...
Did some reading and found out what was going on..
The key is that "pinstX" is defined in "MAPIWIN.H" as "extern LPVOID pinstX;" the key is the "extern" which is apaerntly a external global so all I had to do was add..
LPVOID pinstX;
to the main file (or main header) and now it compiles..
so it now reads
#include <windows.h>
#include <mapiwin.h>
LPVOID pinstX;
//typedef LPVOID pinstX;
/* Per-instance data. */
typedef struct _INST
{
UINT cRef;
LPMALLOC lpmalloc;
} INST, *PINST;
int main()
{
PINST pinst;
pinst = (PINST) PvGetInstanceGlobals();
return 0;
}
Many Thanks
Calvin
|
|
|
|
|
Calvin Streeting wrote: extern LPVOID pinstX;
dose any one have a idea why this won't compile...
Your code compiles fine. It's the linker that is complaining. By using the extern keyword, you've told the linker that the actual declaration of pinstX is found in some other .obj file. Guess what: the linker could not find it.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
hi all
I want to add a hotkey (shortcut key) s.t. when pressing alt+control+shift+p it would do something
(start ms-word with my private diary I tell my self all sorts of thins there....shhhh...)
I tried to make this shortcut keys from a desktop icon but it seems that it stopped working after a few booting of my computer.
anyway I want to succeed in that method of hot key ive been tring to do a little in c++(no mfc) program to add a hotkey using registerhotkey and the message WM_HOTKEY:
but it dont work for me at all (it seems that the shortcut keys dont activate the message WM_HOTKEY)
any help?
thanks
(ive followed the directions in this article
http://www.codeproject.com/system/nishhotkeys01.asp[^][^]
)
here is the abreviated source code of the little program for a hotkey:
int WINAPI WinMain (...){
.
.
.
RegisterHotKey(hwnd, 100, MOD_ALT | MOD_SHIFT | MOD_CONTROL , 'p');
.
.
.
}
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
string execstr;
execstr = ("\"C:\\Program Files\\Microsoft Office\\Office10\\WINWORD.EXE\" \"C:\\Documents and Settings\\DELL\\My Documents\\diary.jjj\"");
switch (message)
{
case WM_DESTROY:
PostQuitMessage (0);
break;
case WM_HOTKEY:
printf ("pressed hotkey");
WinExec (execstr.c_str(),SW_SHOW);
break;
default:
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
|
|
|
|
|
jokop wrote: but it dont work for me at all (it seems that the shortcut keys dont activate the message WM_HOTKEY)
Did you check the return value of RegisterHotKey() ?
Is WindowProcedure() receiving any messages?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
use the following code
RegisterHotKey(hwnd, 100, MOD_ALT | MOD_SHIFT | MOD_CONTROL , 0x50);<br />
intstead of
RegisterHotKey(hwnd, 100, MOD_ALT | MOD_SHIFT | MOD_CONTROL , 'p');<br />
It requires the ASCII in the last argument. and tell me whether it worked or not.
|
|
|
|
|
thanks very much
it works now.
now I have another minor problem:
I want to run this program all the time and I dont want any window of the program to be shown (even as minimized) but the cmd window is present as long as the program is running.
|
|
|
|
|
Can anyone help me with building a toolbar with two vertical columns?
Mark
|
|
|
|
|
Mark_VC wrote: Can anyone help me with building a toolbar with two vertical columns?
Depending on what you need, I can think of a couple ways. One is to just use two toolbars. Another option is to use a "dialog bar" and make the dialog template provide two vertical columns of buttons.
Nathan
|
|
|
|
|
I would really like toolbar by itself so that the program looks professional. I may use calcFixedlayout. If you have a neat way how to do it, please do help.
thanks.
|
|
|
|
|
Mark_VC wrote: I would really like toolbar by itself so that the program looks professional. I may use calcFixedlayout. If you have a neat way how to do it, please do help.
thanks.
I'm afraid I don't understand what your saying. How would a dialog bar look nonprofesional?
Nathan
|
|
|
|
|
A toolbar will wrap the buttons if you set its size appropriately.
A problem, unless there's enough buttons, is that when you resize it to the right size,
it may not fill an entire side of a window.
To get around this, I personally embed the toolbar in a control bar - the control bar always
stays the height of the window and the width of two columns of buttons. The embedded
toolbar is sized appropriately to get the two columns.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
how can i resize it so that the buttons inside it wrap itself. As far as I know, it always aligns button in a single column in vertical toolbar. I tried resizing it, it still shows the buttons in single column. Help please.
Mark
|
|
|
|
|
Make sure the toolbar control has the TBSTYLE_WRAPABLE style.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I tried TBSTYLE_WRAPABLE. It probably works only when the toolbar is floating. When the toolbar is docked, it aligns itself in single column again. I know i have to use calcDynamicLayout and CalcFixedLayout. I do not know who to override them and what code to put in it.
Thanks every one for help though
|
|
|
|
|
It doesn't have to be floating.
You didn't mention MFC before, but now that you've mentioned it -
Override CalcFixedLayout()...
If you return the proper size for the bar it will work.
The width should be the size of two buttons (for two columns).
The height should be the height of the client area of the parent.
For CalcDynamicLayout() I often just route the call to CalcFixedLayout()
unless I need different functionality there - something like:
CSize CMyControlBar::CalcDynamicLayout(int nLength, DWORD dwMode)<br />
{<br />
return CalcFixedLayout(dwMode & LM_STRETCH, dwMode & LM_HORZ);<br />
}<br />
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|