|
pvatanpour wrote: But because in IRAN students don't have technology.
Wrong!
Do you have access to the internet?
If yes, then you have a access to the same technology. At least from a programming point of view.
pvatanpour wrote: But because in IRAN students don't have open sources document.
That does not make sence, if you have access to the internet then you have access to open source documents.
pvatanpour wrote: But because in IRAN students don't have original books.
I do not know about books, just having access to the internet means I do not purchase as many books as I used to. The real problem is finding the information.
I recommend looking at the CP membership list, there is more than one member from your region (part of the world). May be one of them will understand your problem, or can point you in the right direction.
As a general rule: we are programmers (not polititians), sharing knowledge is what we do. Pesonaly, I do not care what your contry of origin is (or your religion).
INTP
Every thing is relative...
|
|
|
|
|
I would like to create a top menu item with a submenu. I am able to create the topmenu item, but not the submenu unser it. This is used in a SDI app.
<br />
void CMyView::CreateOperationMenu()<br />
{<br />
CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();<br />
CMenu* pMainMenu = pMainFrame->GetMenu();<br />
<br />
if (!pMainMenu->InsertMenu(2, MF_BYPOSITION, 0, "Operation"))<br />
return;<br />
<br />
CMenu* pSubMenu = pMainMenu->GetSubMenu(2);<br />
<br />
}<br />
Thanks.
|
|
|
|
|
I'm not exactly sure but I think you need to use MF_POPUP for the top menu item, then create a new menu and insert a menu item into it, then call SetMenuItemInfo() on the top menu item with the MIIM_SUBMENU flag. (for regular Win32 programming anyway, it might be a little different for whatever library (MFC/WTL?) you are using...)
|
|
|
|
|
// The code fragment below shows how to create a new menu for the
// application window using CreateMenu() and CreatePopupMenu().
// Then, the created menu will replace the current menu of the
// application. The old menu will be destroyed with DestroyMenu().
// NOTE: The code fragment below is done in a CFrameWnd-derived class.
// Create a new menu for the application window.
VERIFY(m_NewMenu.CreateMenu());
// Create a "File" popup menu and insert this popup menu to the
// new menu of the application window. The "File" menu has only
// one menu item, that is, "Exit".
VERIFY(m_FileMenu.CreatePopupMenu());
m_FileMenu.AppendMenu(MF_STRING, ID_APP_EXIT, (LPCTSTR)"E&xit");
m_NewMenu.AppendMenu(MF_POPUP, (UINT) m_FileMenu.m_hMenu, "&File");
// Remove and destroy the old menu.
SetMenu(NULL);
CMenu* old_menu = CMenu::FromHandle(m_hMenuDefault);
old_menu->DestroyMenu();
// Add a new menu.
SetMenu(&m_NewMenu);
// Assign a default menu.
m_hMenuDefault = m_NewMenu.m_hMenu;
FAILURE is the first step towards SUCCESS
-- modified at 0:50 Saturday 7th January, 2006
|
|
|
|
|
I posted an article here on the very topic of dynamically building menus.
http://www.codeproject.com/menu/DynaMenuToolbar.asp[^]
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
|
One more question (I hope it will be the last one). How can I repaint the menu? When I dynamicly add menu item to the menu, the new menu is draw only when I point the mouse over it. And things get worst why I delete the menu item. The old menu item still paint under the other until the app is hide and show again.
I have try to invalidate the mainframe, send WM_PAINT message but none of theses work.
Any ideas ?
Thanks.
|
|
|
|
|
Try removing it and putting it back again. I also seem to remember seeing a function that resets the menu for you (part of the CMenu class?). I'll check a liuttle later.
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
-- modified at 18:32 Monday 9th January, 2006
|
|
|
|
|
Hi, this might sound easy for most of you, but i cant create a simple vector of strings without Visual C++ flooding me with warnings even if the program seems to work fine... I would greatly appreciate any enlightment on this issue. Here's the code of a test program that fails :
#include <string>
#include <vector>
#include <iostream>
using std::cout;
using std::endl;
using std::vector;
using std::string;
void main()
{
vector<string> vec;
string s("TEST");
string s2("NEXT");
vec.push_back (s);
vec.push_back (s2);
cout << vec[0] << " : " << vec[1] << endl;
}
and the error report :
C:\Mentor_Projects\TEST vec\testvec\testvec.cpp(25) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_
string<char,std::char_traits<char>,std::allocator<char> > const &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,int>' : identifier was truncated to '255' characters in the debug information
C:\Mentor_Projects\TEST vec\testvec\testvec.cpp(25) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string
<char,std::char_traits<char>,std::allocator<char> > &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,int>' : identifier was truncated to '255' characters in the debug information
c:\program files\microsoft visual studio\vc98\include\vector(39) : warning C4786: 'std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >
>::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >' : identifier was truncated to '255' characters in the debug information
c:\program files\microsoft visual studio\vc98\include\vector(60) : warning C4786: 'std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >
>::~vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >' : identifier was truncated to '255' characters in the debug information
|
|
|
|
|
These are the usual (no joke) warnings, not errors, when you use STL with VC++ 6.0.
Workaround: Write the following before all #include files:
#if defined (_MSC_VER) && _MSC_VER <= 1200 // MSVC++ 6.0
# pragma warning(disable: 4786)
#endif
BTW, if possible upgrade to a recent VC++ version.
|
|
|
|
|
Thanks a lot! I thought it was weird to have all these warning for such a simple little code that looked fine to me. I'll see what i can do for a more recent version. thanks again
|
|
|
|
|
See here.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
Actualy it has not been an easy problem, becuase it has irritated a great many of us. This is a known bug and has apparently not been fix in versions of the compiler beyound VC6.
Many Microsoft headers try to solve the problem by placing #pragma warning(disable:4786) before including the header files.
I have found that placing
#pragma warning(disable:4786)
before the headers and placing
#pragma warning(disable:4786)
after the headers, usualy solves the problem.
The real problem with this warning is that we should not get in the habit or ignoring warnings. Because some of the warnings are very important. This is just not one of them.
INTP
Every thing is relative...
|
|
|
|
|
I have gotten all the way up to the point were the bitmap is drawn on the windows ap. Now I basically am trying to get the bitmap to float around never leaving the bounds of the the ap. So if it hits a side of the ap (width or height) then it is just going to bounce off and go another way. Kind of like that one game were there was a paddle at the bottom of the screen and you had to bounce a ball towards the top were you broke down bricks. Anyways, take a look at the last function...
#include <windows.h><br />
#include <winuser.h><br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <time.h><br />
<br />
#define APPTITLE "Game Loop"<br />
<br />
LRESULT CALLBACK WinProc(HWND,UINT,WPARAM,LPARAM);<br />
ATOM MyRegisterClass(HINSTANCE);<br />
BOOL InitInstance(HINSTANCE,int);<br />
void DrawBitmap(HDC,char*,int,int);<br />
void Game_Init();<br />
void Game_Run();<br />
void Game_End();<br />
<br />
HWND global_hwnd;<br />
HDC global_hdc;<br />
<br />
LRESULT CALLBACK WinProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)<br />
{<br />
global_hwnd = hWnd;<br />
global_hdc = GetDC(hWnd);<br />
<br />
switch (message) <br />
{<br />
case WM_DESTROY:<br />
Game_End();<br />
PostQuitMessage(0);<br />
break;<br />
}<br />
return DefWindowProc(hWnd, message, wParam, lParam);<br />
}<br />
<br />
ATOM MyRegisterClass(HINSTANCE hInstance)<br />
{<br />
WNDCLASSEX wc;<br />
wc.cbSize = sizeof(WNDCLASSEX); <br />
<br />
wc.style = CS_HREDRAW | CS_VREDRAW;<br />
wc.lpfnWndProc = (WNDPROC)WinProc;<br />
wc.cbClsExtra = 0;<br />
wc.cbWndExtra = 0;<br />
wc.hInstance = hInstance;<br />
wc.hIcon = NULL;<br />
wc.hCursor = LoadCursor(NULL, IDC_ARROW);<br />
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);<br />
wc.lpszMenuName = NULL;<br />
wc.lpszClassName = APPTITLE;<br />
wc.hIconSm = NULL;<br />
<br />
return RegisterClassEx(&wc);<br />
}<br />
<br />
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)<br />
{<br />
HWND hWnd;<br />
<br />
hWnd = CreateWindow(<br />
APPTITLE,
APPTITLE,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
500,
400,
NULL,
NULL,
hInstance,
NULL);
<br />
if (!hWnd)<br />
return FALSE;<br />
<br />
ShowWindow(hWnd, nCmdShow);<br />
UpdateWindow(hWnd);<br />
<br />
return TRUE;<br />
}<br />
<br />
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)<br />
{<br />
int done = 0;<br />
MSG msg;<br />
<br />
MyRegisterClass(hInstance);<br />
<br />
if (!InitInstance (hInstance, nCmdShow)) <br />
return FALSE;<br />
<br />
Game_Init();<br />
<br />
while (!done)<br />
{<br />
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) <br />
{<br />
if (msg.message == WM_QUIT)<br />
done = 1;<br />
<br />
TranslateMessage(&msg);<br />
DispatchMessage(&msg);<br />
}<br />
Game_Run();<br />
}<br />
<br />
return msg.wParam;<br />
}<br />
<br />
void DrawBitmap(HDC hdcDest, char *filename, int x, int y)<br />
{<br />
HBITMAP image;<br />
BITMAP bm;<br />
HDC hdcMem;<br />
<br />
image = LoadImage(0,"w.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);<br />
<br />
GetObject(image, sizeof(BITMAP), &bm);<br />
<br />
hdcMem = CreateCompatibleDC(global_hdc);<br />
SelectObject(hdcMem, image);<br />
<br />
BitBlt( <br />
global_hdc,
x, y,
bm.bmWidth, bm.bmHeight,
hdcMem,
0, 0,
SRCCOPY);
<br />
DeleteDC(hdcMem);<br />
DeleteObject((HBITMAP)image);<br />
}<br />
<br />
<br />
void Game_Init()<br />
{<br />
<br />
srand(time(NULL));<br />
}<br />
<br />
void Game_Run()<br />
{<br />
char buffer[80];<br />
static iCount = 0;<br />
int x = 0, y = 0;<br />
RECT rect;<br />
GetClientRect(global_hwnd, &rect);<br />
<br />
DrawBitmap(global_hdc, "c.bmp", x, y);<br />
<br />
iCount++;<br />
sprintf(buffer,"%d",iCount);<br />
TextOut(global_hdc,0,10, buffer,strlen(buffer));<br />
}<br />
<br />
<br /> If you take a look you will notice I am trying to get this accomplished in the Game_Run(). As of now the bitmap is drawn in the top left corner of the form (0,0) The stuff that is commented out is some things I was working on but failing at.
How do you create an object of the actual instance of the bitmap I a trying to get to move?
Thanks
Chad
|
|
|
|
|
Okay so when you're calling:
BitBlt(global_hdc, x, y, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
Just change those x and y values each time the function is called.
Then check them using:
RECT rt;
GetClientRect(global_hwnd, &rt);
if (x < rt.left)
blab blah, bounce right
if (y > rt.bottom)
blah blah, bounce up
etc.
Couple other tips:
Do not call LoadImage, CreateCompatibleDC, DeleteImage, DeleteObject, in your DrawBitmap function.
Load the image into a global variable, create the compatible DC as a global, and keep re-using both of those rather than re-allocating memory each frame - you will probably get a crudload of lag if you keep re-creating and loading your images and device contexts every frame, depending on how large and what type of bitmap you're loading.
Storing the double-buffered device context as a global variable will mean that you're going to want to clear your created device context using FillRect each frame so that remnants of the old drawings do not get left behind.
Kelly Ryan
|
|
|
|
|
I did not study your code, bcause how you create the client area and display the bitmap is irrelivant.
You need to know where the borders are, if x or y is less than zero then the object should be bouncing in the opposit direction. That is, if left is negitive and x becomes 0 or less, then reverse the sign (which indicates direction).
If you are drawing the bitmap on the client area, then it is not possible for you to draw it any where else. If you draw a 10x10 image at {x = -10, y = -10}, then you will not see it at all. If it hits the right boarder (wall) x = 0, no problem, but if the x value becomes -1 (and you want it to bounce), then you reverse it by making x = +1.
Experiment by bouncing rectagles of the walls.
INTP
Every thing is relative...
|
|
|
|
|
I have a CDialog class and I added a CTabCtrl from the controls toolbox to the dialog and set the labels for the tabs (5 tabs in all). I then created five more dialog boxes (each is WS_CHILD|WS_VISIBLE). I now need to know how to add these new dialogs to the tab control so that I can use the controls on each dialog.
Thanks,
Mark
|
|
|
|
|
The answer to your question is much larger in scope than can be efficiently posted here. I recommend that you scn the articles posted on CP for a solution. There is bound to be something you can use as an example.
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thanks for the re John. Well here is the thing..., I have an MDI app with a CTreeCtrl view on the left in a docked window and the view on the right. Another docked view at the bottom contains a CDialog box and I wanted to add tabs pages for various controls within this dialog. Is there a better way to do this other than a CTabCtrl?
Mark
-- modified at 14:41 Saturday 7th January, 2006
|
|
|
|
|
You could do a dialogbox that contains an embedded propertysheet. I would suggest just using a propertysheet, but then you have to deal with hiding the buttons, and dealing with the resulting gap at the bottom of the propertysheet (when you hide the buttons, it still pads the bottom of the sheet).
I have some code that does this embedded propertysheet thing if you want it.
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Ok since my last post I figured out how to use the CTabCtrl and it is working. Now I need to conquer a resizing issue. Most of the examples that I have seen deal with demos that are in fixed dialogs. My dialog is resized and the page for each tab is beyond the parent container’s borders. The tab control seems to resize on it’s own as the parent dialog is resized, but not the child dialog (tab pages). Which OnSize handler do I use to resize the pages? For example.
CTabDialog (CDialog)
|
----- CMyTabCtrl (CTabCtrl)
|
------- m_iTab[0]
|
------- TabPage1 (Child CDialog)
Thanks!
|
|
|
|
|
I would try this:
In your parent dialog's OnSize handler, calculate the new window size for the child dialogs and call MoveWindow().
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Fixed it. In the parent dialog the OnSize handler was resizing the tab control fine the child dialogs were not resizing. I added a public function ResizePage() to the CMyTabCtrl class and called it in the parent OnSize handler as well as when a tab was selected. Now no matter what happens the child dialogs are resized to fit the tabs correctly.
Thanks for the help.
"Nothing is impossible, remember when the world was flat?"
Mark
|
|
|
|
|
I am getting a crash inside InternetConnect and I can't for the life of me figure out why. It seems only to happen when I pass INTERNET_SERVICE_FTP -- I have a test program which does nothing but create a CInternetSession, then call GetHttpConnection, then call GetFtpConnection, passing valid IP addresses to both functions. GetHttpConnection returns successfully. GetFtpConnection crashes with an illegal memory access (and an overwritten stack) after the CFtpConnection constructor calls InternetConnect. Is there anything I can do to repair this short of reinstalling Windows? (The install is Windows 2000 sp 4.)
|
|
|
|
|
Hi,
I want write small a application which draw`s a graph,taking x-axis values from 300 to 900 and y-axis values from 0 to 100.I want to graph to smooth and linear.If any one already written any article on this issue please let me know.
Thank in before
James
|
|
|
|
|