|
First of all you don't initialize the variable 'n' in your code. so p1[n] is an invalid location. When you try and store a value at that place it would be throwing an error or possibly a crash. Can you just check if this is the root cause?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
thank you .i have find it .a little mistake led on to a great error.
|
|
|
|
|
hey hi all... i made a c++ program in which i need to detect USB device inserted event... but my windowProc function is not getting called.. i don't know whats wrong with the program.... i also tried to check the error by using GetLastError() but i got nothing.. code goes like this
#ifdef WINVER
#undef WINVER
#endif
#define WINVER 0x0501
#include
#include
#include
#include
#include
DEFINE_GUID(GUID_DEVINTERFACE_VOLUME, 0x53f5630dL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
// don't know if this is the correct GUID for USB device interface... i got it from MSDN website....
#define guid GUID_DEVINTERFACE_VOLUME
using namespace std;
HDEVNOTIFY RegisterDeviceNotificationA(
HANDLE hRecipient,
LPVOID NotificationFilter,
DWORD Flags
);
#define RegisterDeviceNotification RegisterDeviceNotificationA
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // device-change event
LPARAM lParam // event-specific data
);
int main( )
{
HWND hwnd = FindWindow( "ConsoleWindowClass", NULL);
cout<<hwnd<<endl; to="" check="" if="" im="" able="" get="" hwnd="" or="" not......
dev_broadcast_deviceinterface="" notificationfilter;
zeromemory(="" ¬ificationfilter,="" sizeof(notificationfilter)="" );
notificationfilter.dbcc_size="sizeof(DEV_BROADCAST_DEVICEINTERFACE);
NotificationFilter.dbcc_devicetype" =="" dbt_devtyp_deviceinterface;
notificationfilter.dbcc_classguid="guid;
HDEVNOTIFY" hdevnotify;
hdevnotify="RegisterDeviceNotification(" hwnd,="" device_notify_window_handle);
cout<<hdevnotify<<endl;="" the="" value
if(="" !hdevnotify="" )
{
cout<<"registration="" of="" device="" notification="" failed"<<endl;
}
else
{
cout<<"registration="" complete"<<endl;
}
dword="" dword;
dword="GetLastError(" );
cout<<dword<<endl;="" for="" any="" error="" any....
while(1)
{
sleep(1000);
}
return="" 0;
}
lresult="" callback="" windowproc(="" uint="" umsg,="" wparam="" wparam,="" lparam="" )
{
cout<<"windowproc="" called"<<endl;="" its="" getting="" called="" not.......
if(="" umsg="=" wm_devicechange="" )
{
cout<<"device="" change"<<endl;
}
return="" defwindowproc(hwnd,umsg,wparam,lparam);="" call="" window="" api="" function="" defwindowproc()="" which
="" provides="" default="" message="" processing="" messages="" that="" were="" not="" processed="" by="" this="" window.
}
output="" is
0x290392="" hwnd
0x245d08="" hdevnotify
registration="" complete
0="" getlasterror()
and="" nothing="" is="" happening="" when="" inserting="" usb.....nyone="" knw="" about="" this
bye="" have="" a="" nice="" day.....=""
<div="" class="ForumSig">bye have a nice day.....
|
|
|
|
|
$w0rdf1$h wrote:
HDEVNOTIFY RegisterDeviceNotificationA(
HANDLE hRecipient,
LPVOID NotificationFilter,
DWORD Flags
);
#define RegisterDeviceNotification RegisterDeviceNotificationA
Why are you re-prototyping this function?
$w0rdf1$h wrote: ...my windowProc function is not getting called.
Why would you expect it to?
"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
|
|
|
|
|
my compiler was saying.... registerDeviceNotification() undeclared.... so i search google.. n put this frm there... now i also tried without prototype.. with correct header files inclueded.. now i am not getting that error but my program is also not working..im not getting any notification.....i can do this using win32 api with winMain() as entry point in place of main().. but point is that i want my program to run in background....i can hide console using ShowWindow(hwnd,1) but i dont know how to hide top level window created in winMain()?????
bye have a nice day.....
|
|
|
|
|
$w0rdf1$h wrote: my compiler was saying.... registerDeviceNotification() undeclared
And rightly so, since registerDeviceNotification() does not exist.
$w0rdf1$h wrote: ...but my program is also not working..im not getting any notification...
Why would you expect to?
$w0rdf1$h wrote: i can do this using win32 api with winMain()...
Probably so (assuming you capitalized it correctly), since it likely has a message pump.
$w0rdf1$h wrote: i want my program to run in background...
What does that have to do with using main() in place of WinMain() ?
"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
|
|
|
|
|
see i found it on MSDN that function registerDeviceNotification(...,...,... )
registers for windows service that sends notification to window whose HWND is registered( passing it as a parameter)....and its a function in WIN32 API.. so y should i get a no such function exist error...
see this...
http://msdn2.microsoft.com/en-us/library/aa363431.aspx[^]
bye have a nice day.....
|
|
|
|
|
C++ is case sensitive, so registerDeviceNotification is not the same as RegisterDeviceNotification.
|
|
|
|
|
yaa i knw.... im srry i posted in forum registerDeviceNotification(..)... but i the one i used in my program is RegisterDeviceNotification(...)... u can see it in my first post....
bye have a nice day.....
|
|
|
|
|
Could you please write in proper english ? A lot of people here are not native english speaker and deciphering SMS messages is really a pain.
For your question: did you include Winuser.h ?
And, why do you want absolutely use windows API in a console application. You don't have a message loop so how could you receive windows notification messages ? David already told you so.
Why don't you simply create a Win32 app, create a window and don't show it ?
|
|
|
|
|
ohh sorry... i will take care of that in future......
Now I am using WinAPI and not using console.....
i have created a window and hide it using showWindow(hwnd,0) and this is working fine...now no need to panic... thanx....
bye have a nice day.....
|
|
|
|
|
Can anybody help me help me to remove and add Caption Bar of a dialog at runtime.
I have created a dialog through resource with a caption bar.
I want to remove completely the caption on clicking the Button1 on the dialog and add the caption bar on click of button2 on the dialog.
Though on click of Button1 the caption bar is still there but the dialog is not movable whereas when i click Button2 I am able to move the dialog on selecting the Caption bar.
Can anybody suggest the way where the caption will be completely removed and caption appears as per our requirement.
void CCaptionWndDlg::OnButton1()
{
ModifyStyle(WS_BORDER|WS_CAPTION,0);
CRect aRect;
GetWindowRect(&aRect);
::SetWindowPos(m_hWnd,HWND_TOP,aRect.top,aRect.left,aRect.Width(),aRect.Height(),SWP_NOZORDER | SWP_NOACTIVATE);
}
void CCaptionWndDlg::OnButton2()
{
ModifyStyle(0, WS_BORDER|WS_CAPTION);
CRect aRect;
GetWindowRect(&aRect);
::SetWindowPos(m_hWnd,HWND_TOP,aRect.top,aRect.left,aRect.Width(),aRect.Height(),SWP_NOZORDER | SWP_NOACTIVATE);
}
|
|
|
|
|
naveen.V wrote: ::SetWindowPos(m_hWnd,HWND_TOP,aRect.top,aRect.left,aRect.Width(),aRect.Height(),SWP_NOZORDER | SWP_NOACTIVATE);
replace with
::SetWindowPos( m_hWnd, 0,0,0,0,0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_DRAWFRAME );
|
|
|
|
|
Thanks a lot.Its Working!!!!!
|
|
|
|
|
Thanks a lot Naveen.. SWP_DRAWFRAME did the trick.
|
|
|
|
|
Naveen.R wrote: ::SetWindowPos( m_hWnd, 0,0,0,0,0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_DRAWFRAME );
FYI: SWP_DRAWFRAME can be specified in the ModifyStyle itself
- NS -
|
|
|
|
|
NS17 wrote: FYI: SWP_DRAWFRAME can be specified in the ModifyStyle itself
Ya I forgot. BTW ModifyStyle() internally does the same thing...
|
|
|
|
|
The following code will do the trick...
void CCaptionWndDlg::OnButton1()
{
ModifyStyle( WS_BORDER | WS_CAPTION, 0, SWP_DRAWFRAME );
}
void CCaptionWndDlg::OnButton2()
{
ModifyStyle( 0, WS_BORDER | WS_CAPTION, SWP_DRAWFRAME );
}
- NS -
|
|
|
|
|
Thanks a lot.Its Working!!!!!
|
|
|
|
|
SWP_DRAWFRAME can be specified in the ModifyStyle itself. So no need to call SetWindowPos explicitly. See the MSDN documention for more details.
- NS -
|
|
|
|
|
... or supported MIME-Types?
I try to code a tiny Multimedia-App (which also uses DirectShow). For error handling, i need to know something about the capabilities of the desired Viewer (supported Audio- / Videocodecs). Any idea, how to get a list of installed codecs on the local machine? I dont know where to look :-|
Hints are very welcome :-|
|
|
|
|
|
I think you should be able to know installed software (i.e. codecs) through browsing in the registry. I can help you much more, bit if you look "registry" in the forum you will find a lot of interestan messages that maybe give you ideas.
hope it helps.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Hi,
I need a timeline control panel like Macromedia's Flash or Adobe Premier. I did not find anything in the Web.
Where can i find such o control Free or Commercial ?
Regards,
sdancer75
|
|
|
|
|
if you can spell out your actual requirement, then i can develop one such for you.
i love to develop active X controls.
|
|
|
|
|
Hello community,
i try to debug my project on dualcore machine, and if i set a breakpoint to watch the content
of my variables, for exemple CStrings, VS show only the first character???
Example:
CString csFilePath = "C:\\foldername\\file.txt";
In watch window i can see only 'C', where is the rest of csFilePath????
Thanks for any help!!!
termal
|
|
|
|