|
For some reason, the OP deleted their post.
|
|
|
|
|
Hi folks
I've created a class that create dynamic menus this is the code of the method that creates hte menus:
<br />
void Menu::InsertNewMenuItem(HMENU hParentMenu, HWND hwWindowOwner, unsigned int uiMenuID, unsigned int uiMenuBehavior, char * cMenuText)<br />
{<br />
int iSize = m_uiMenuID.size();<br />
m_uiMenuID.push_back(uiMenuID);<br />
m_uiBehavior.push_back(uiMenuBehavior);<br />
m_cMenuName.push_back(cMenuText);<br />
if(iSize <= 0)<br />
{<br />
AppendMenu(hParentMenu, m_uiBehavior[0], m_uiMenuID[0], m_cMenuName[0]);<br />
m_hSubMenu = CreateMenu();<br />
}<br />
else<br />
{<br />
AppendMenu(m_hSubMenu, m_uiBehavior[iSize], m_uiMenuID[iSize], m_cMenuName[iSize]);<br />
AppendMenu(hParentMenu, m_uiBehavior[0], (unsigned int)m_hSubMenu, m_cMenuName[0]);<br />
}<br />
SetMenu(hwWindowOwner, hParentMenu);<br />
}<br />
This code is in my callback
<br />
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT uiMessage, WPARAM wParam, LPARAM lParam)<br />
{<br />
HMENU hMainMenu = CreateMenu();<br />
char * cMainName = "Principal1";<br />
char * cName1 = "Menu 1";<br />
char * cName2 = "Menu 2";<br />
char * cName3 = "Menu 3";<br />
char * cName4 = "Menu 4";<br />
char * cName5 = "Menu 5";<br />
char * cName6 = "Principal2";<br />
char * cName7 = "Menu 7";<br />
char * cName8 = "Menu 8";<br />
char * cName9 = "Menu 9";<br />
char * cName10 = "Menu 10";<br />
int iIDS[] = {6000, 6001, 6002, 6003, 6004, 6005, 6006, 6007, 6008, 6009, 6010};<br />
switch(uiMessage)<br />
{<br />
case WM_CREATE:<br />
{<br />
theMenu = new Menu();<br />
theMenu2 = new Menu();<br />
break;<br />
}<br />
case WM_CHAR:<br />
{<br />
switch(wParam)<br />
{<br />
case 'a':<br />
{<br />
theMenu->InsertNewMenuItem(hMainMenu, hwnd, iIDS[0], MF_STRING|MF_POPUP, cMainName);<br />
DrawMenuBar(hwnd);<br />
break;<br />
}<br />
case 's':<br />
{<br />
theMenu2->InsertNewMenuItem(hMainMenu, hwnd, iIDS[1], MF_STRING, cName1);<br />
DrawMenuBar(hwnd);<br />
break;<br />
}<br />
.....<br />
The problem that I have is: I have 2 menus. When I call the method pressing "a", a submenu is inserted in the first menu. When I call the method pressing "s" to insert a new submenu in the OTHER menu, the first one is overlapped with the first. The same is valid when I insert a submenu in the second menu and insert a valid a submenu in the first menu.
What going on? It's very strange. Am I clear enough for you?
|
|
|
|
|
The first problem I see is that you're calling
HMENU hMainMenu = CreateMenu(); for every window message, I don't think that is what you're after. You can get your window's menu with GetMenu() .
|
|
|
|
|
Hi,
I wanna make an app and in the about box to have a small animated 3D thingy with DirectX but dont want to static link* to d3d.lib or w/e ....
except LoadLibrary and GetProcAddress for every dll and proc i need, is there another way
*this is because ,if the target machine doesnt have directx ,should run but the about box should say "...no directx... bla bla" u understand what is what i want right?
|
|
|
|
|
shaderx wrote: I wanna make an app and in the about box to have a small animated 3D thingy with DirectX but dont want to static link* to d3d.lib or w/e ....
You mean you don't want dynamic linking but static linking ? I don't thing that is possible.
shaderx wrote: except LoadLibrary and GetProcAddress for every dll and proc i need, is there another way
That is still dynamic linking, except that you explicitely load the dll (but you still need the dll to be present on the target machine).
shaderx wrote: u understand what is what i want right?
I'm not so sure...
In brief, you will need to distribute DirectX with your application if you want to use it.
|
|
|
|
|
shaderx wrote: if the target machine doesnt have directx
I think DirectX came installed on all current OS supported by Microsoft so that should not happen. What may not be present is the Version you coded against. See this[^]
led mike
|
|
|
|
|
AFAIK there is no static lib version of DirectX.
|
|
|
|
|
i see ppl dont understand what i mean,and what i mean is:
is there an easyer way to use diretx without linking at load time with it , except LoadLibray and GetCrocAddress for every proc ?
|
|
|
|
|
shaderx wrote: is there an easyer way to use diretx without linking at load time with it , except LoadLibray and GetCrocAddress for every proc ?
I believe what people mean is "no, there isn't".
Mark
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
//hi the type of threading im using is..
#include
#include
using namespace std;
int shutdown=0;
int main(){
unsigned sid;
(HANDLE)_beginthreadex( NULL, 0, threadprocess, NULL, 0, &sid);
while(1){
Sleep(1000);
if(shutdown==1){ break; }
}
}
unsigned __stdcall threadprocess(void *params){
return 0;
}
//What i need to do is pass a string from the main() to the threadprocess.. Please Help.
//I alsot need to send a string back to the main process
//Could be a SOCKET i need to pass back or something for example
//but i know i could just put global string but it needs to separate per proccess ran...
-- modified at 14:47 Thursday 22nd March, 2007
|
|
|
|
|
Whatever you pass as the 4th param to _beginthreadex will be the "params" param in your
threadprocess.
Mark
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
error C2664: '_beginthreadex' : cannot convert parameter 4 from 'std::string' to 'void *'
If i can get this working i can mod my app quite a bit and do many more functions much more efficiently...
|
|
|
|
|
A 'std::string is not a pointer. The size of the parameter passed is the size of a pointer so
that's the largest object you can pass.
Maybe passing the address of your 'std::string' will work. You'll have to cast it back to
a pointer to a std::string in your threadproc.
See DavidCrow's reply.
Mark
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
|
darkcloud.42o wrote: //What i need to do is pass a string from the main() to the threadprocess.. Please Help.
void __cdecl threadprocess( void *params )
{
char *p = (char *) params;
strcat(p, "World");
}
void main( void )
{
char *s = new char[12];
strcpy(s, "Hello ");
_beginthread(threadprocess, 0, s);
...
delete [] s;
s = NULL;
}
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
ic that appears to be working but i need to have the char s to be used right after the threadprocess completes... which is modified inside threadprocess... see what i mean..
|
|
|
|
|
darkcloud.42o wrote: ...i need to have the char s to be used right after the threadprocess completes... which is modified inside threadprocess... see what i mean..
If you are creating a secondary thread, and then just waiting for it to complete, why bother creating it?
In any case, you'll need to implement some sort of synchronization object.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
cause i want to have it on a separate thread because it will serv up to 3-10 diff functions each function must be able to operate simultaniously..
eg... it will execute 1-10 threads at once per motherthread and wait for return here...
plus i need to use this thread outside the motherthread so its used all over the freeking app....
I have the threads part setup and it will work.. but i have to have the return on that variable.. could be a socket in some other thread some other time... believe me there are networking situations where this is required...
i see what your saying i could do it another way with limited function... but i will save days of programing/debugging..
I tell you what you contact me via email and ill send you my app what ive got here...
darkcloud.42o@gmail.com
-- modified at 17:10 Thursday 22nd March, 2007
|
|
|
|
|
This code leaks the thread HANDLE . From MSDN: "the handle returned by _beginthreadex has to be closed by the caller of _beginthreadex".
If you don't need the HANDLE make your code look soemthing like this:
HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, threadprocess, NULL, 0, &sid);
CloseHandle(hThread);
Note that closing the HANDLE doesn't terminate the thread. You may want to add error checking which I didn't include in my example.
Steve
|
|
|
|
|
Hey if you can convert a handle to socket.. it would work... is it possible...
|
|
|
|
|
I don't understand.
Steve
|
|
|
|
|
Ok so i got the variable passed to child threads and they can function..
but i need to pass more than 1 variable to the thread char* s and SOCKET ls;
lets not worry about the return on the child thread right now.... if i can 2 variables passed the whole process can be done inside child thread..
but one question... about that.. unsigned __stdcall test(void* params){ return 3; ) this return here how can i axs that??? can i access a process like int test(){ return 0; } be accessed from open threads at the same time?
btw
rigth now its FTP/WEB SERVER with Advanced custom admin functions with GUI.
-- modified at 12:40 Friday 23rd March, 2007
|
|
|
|
|
hi,
i am doing a prj on face detection. i have now captured and saved the images in VC++ but nw hace to detect only the face part from the entire image..
u hav any clue how to implement it in VC++ ????
|
|
|
|
|
That's way to broad a question for a forum. You should google for articles on what is a huge topic.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|