|
In that case, you need to make yourself a modeless dialog box[^] on which you can put your message.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hmmm, this might work.
DWORD dwID =0;
MSGBOXPARAMS msg = {0};
msg.cbSize = sizeof(MSGBOXPARAMS);
msg.hwndOwner = this->m_hWnd;
msg.hInstance = GetModuleHandle(NULL);
msg.lpszText = _T("Blocking is for bullies.");
msg.lpszCaption = _T("Non-blocking");
msg.dwStyle = MB_OK | MB_SETFOREGROUND;
CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)MessageBoxIndirect,&msg,0,&dwID);
Make sure not to create the MSGBOXPARAMS on the stack you probably want it to be persistent. You might be able to check if the user has clicked the OK button by checking GetExitCodeThread Function[^] for STILL_ACTIVE.
Let me know if it works.
Best Wishes,
-David Delaune
|
|
|
|
|
How Could we make a field or fields of database primary key for that database using Dao Database?
CDaoTableDef tableDef(&m_db);
tableDef.Create(m_tableName.c_str());
tableDef.CreateField(m_field1.c_str(),dbText,1,dbFixedField);
tableDef.CreateField(m_field2.c_str(),dbText,255,dbVariableField);
tableDef.Append();
tableDef.Close();
I want to make my secound field primary key in my database.
|
|
|
|
|
I think you need to use the CreateIndex[^] method. The CDaoIndexInfo structure[^] lets you specify that an index is primary (i.e. the primary key) or foreign (foreign key).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi everyone,
I have a modal dialog box which is called by the main thread. This dialog has no parent (appears at center screen, overlapped, and shown in taskbar). When the user clicks "Save" in the dialog, the dialog procedure receives the command and displays a save file dialog (GetSaveFileName).
The problem is that the second dialog (Save Dialog) doesn't work at all. It can't be activated, and seems kind of frozen (can't be closed, buttons and scroll bars are frozen). Here's my code:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
DialogBox(hInstance, MAKEINTRESOURCE(101), NULL, DialogProc);
MSG msg;
while (GetMessage(&msg, NULL, 0, 0) != 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
INT_PTR CALLBACK DialogProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
HDC hdc; PAINTSTRUCT ps;
switch (message) {
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDSAVE:
OPENFILENAME OFN;
OFN.hwndOwner = hWnd;
[...]
if (GetSaveFileName(&OFN)) {[...]}
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return true;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
break;
case WM_INITDIALOG:
[...]
return true;
case WM_CLOSE:
[...]
return true;
case WM_DESTROY:
[...]
return true;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return false;
}
Whatever dialog type I put at this line (print dialog, modal dialog, modeless dialog), it doesn't behave properly. What am I missing?
I tried with OFN.hwndOwner = NULL, but doesn't work.
Thanks in advance!
|
|
|
|
|
The problem may well be in the [...] stuff.
I know the OPENFILENAME struct has lots of members - some refer to hooks, and instances of replacement dialog templates, etc.
At the very least, put in a
memset(&ofn, 0, sizeof(ofn));
line! (Parameters from memory. If you do not check them, you may lose your home, etc).
Also, pretty critically, there's a lStructSize member of ofn too! I suspect this needs filling in.
Good luck,
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
No it is not! The problem does not lie within the save file dialog, but rather within the dialog procedure and/or API calls. If I replace the save file dialog part with a print dialog or even a new modal or modeless dialog, the problem still occurs. The second dialog shows itself but is unusable.
Thanks for your reply though
|
|
|
|
|
Problem solved. The problem was within the procedure. Replaced "return DefWindowProc(hWnd, message, wParam, lParam)" by "return false". return DefWindowProc is for main windows, not dialogs.
|
|
|
|
|
Hi,
I am trying to write a small application, using Visual C++.
In the application's GUI, among other things, there will be 2 buttons:
First button should turn the PC's internal speaker ON.
Second button should turn the PC's internal speaker OFF.
The GUI will have to be functional during all times.
I see that in order to use the PC's internal speaker I need to use the Beep(int tone, int duration) function. (or is there any other way ???)
The problem is that Beep function will play sound and stop the code's execution until duration mSec will be over.
This is not good to me, as I will need the program to continue do other things in the background and I will need it to response to the OFF button as well.
Using a flag to repeat the short Beeps again and again in a loop produces a glitch in the sound, every time that the Beep is executed (looped) again, so this is not elegant solution that I wold like to use.
The solution that I came to is:
ON button will start a thread, that will Beep endlessly.
OFF button will Beep for 1 mSec, and this way will terminate sound that the Beep from the BeepThread started.
Note that the Beep's thread called from ON button will never finish execution as it will be stack in it's Beep() line that has endless time as parameter.
The problem in my solution is that even if the sound stops, the BeepThread that was started will never end, and pressing several times on the on/off buttons will produce several BeepThreads.
Killing a thread from the outside is not recommended as well.
Any ideas on how to deal with this issue ?
I am open to change the whole way of my solution.
Thanks.
|
|
|
|
|
Why dont you loop beep function with finite time inside the thread, say 5 seconds? This way when off is clicked the sound will stop immediately and thread will terminate in at most 5 seconds.
void thread_func()
{
while(!done)
{
beep(5000);
}
}
void off_func()
{
beep(1);
done = false;
}
-Saurabh
|
|
|
|
|
Thanks for your comment.
As I wrote before, I did so, but the problem is that this caused a short noise every time interval.
In the case of your suggestion, the noise will come out every 5 seconds.
The noise is an outcome of the beep being stopped and immediately started again, so the tone is not continuously.
This noise is a problem, as the tone that I produce should come out clean.
Any other suggestions ?
Thanks.
|
|
|
|
|
Hi,
Can anyone help me here ?
I would really appreciate getting ideas for my problem.
-- Amit.
|
|
|
|
|
Does anyone know what DLL the image of the standard image list IDB_VIEW_SMALL_COLOR is stored in? You can see some of it in this screenshot: http://www.airwebreathe.org.uk/IDB_VIEW_SMALL_COLOR.png[^]. I might expect it to be in comctl32.dll with other common image lists... but it's not - only the old 4-bit version of the image.
This is all helping the development of Wine (windows apps running on linux).
Joel Holdsworth
|
|
|
|
|
hi..
my current problem is i have message keep coming to my local system port from one of my networked computer..
that is through socket programming(using udp).. and the application which im running in my system is win32 not mfc based...
and my project doesn't allow me to use mfc (might sound strange.. where cAsynchronous class is the only solution for an asynchronous UDP socket, i googled so far..).. and if there is a way to read incoming message (asynchronously and doesn't block my execution..so that i run the rest of my processes which include my menu handling, and blah, blah, blah, is there is a message of some type i should read it as it comes.. otherwise do my rest of the processess)....
previously just to recieve some msg outside mfc using udp i worked with recievefrom and other recieve functions that come with udp socket class members.. (and i even don't need the need to notify the incoming message thats why i went to udp not tcp..)
so finally what i need is just recieve message buffer from my local port.. and my work is done...
|
|
|
|
|
I'd have a look at the following article:
http://www.flounder.com/kb192570.htm[^]
Basically - don;t touch MFC's socket objects with a barge pole - put socket code in a different thread, and post messages to your main UI thread.
Enjoy the read - and look at the other essays on that site.
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Hello all!
I use the visual c++. I got this error: fatal error C1852: 'Release\Autorun.pch' is not a valid precompiled header file
The pch creating when the compile progress,but when the compile complete then the pch file deleting.
Thanks for all helps!!
|
|
|
|
|
Have you tried a "rebuild all"?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi,
Please if you can advise on following questions on integration with QuickBooks.
1. I need to connect to QuickBooks database. How can I connect and retrieve data from QuickBooks?
2. What type of connection do you use to connect to database?
3. Is there some tool that makes it easier?
Please answer on any questions of this, if you have programmed with QuickBooks.
Thanks in advance
John T.
|
|
|
|
|
Don't spam the forums. You should choose one forum and ask your question on the one only. That's in the rules.
|
|
|
|
|
ODS_HOTLIGHT 's not work with CListBox. Why? How to solve this?
|
|
|
|
|
I don't think the list box control has "hot track" features (correct me if i am wrong). Try using a list view (CListCtrl / SysListView32) instead, or use WM_MOUSEMOVE and TrackMouseEvent[^] to add this feature yourself. Shouldn't be that complicated.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
I'm sorry, but i have no idea about this. This's ListBox. How to get the item that mouse 's hover with TrackMouseEvent()?
|
|
|
|
|
Well, you don't get that item with TrackMouseEvent, what you can do is handling WM_MOUSEMOVE, you can find the item the mouse is over using ItemFromPoint[^], and you use TrackMouseEvent to know when the mouse leaves since by default you get no message whatsoever about that. But to save yourself all the trouble figuring this out, you should really consider CListCtrl[^] instead, just like Iain suggested too.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
|
Hello,
I would like to emit the lable addresses from a bit of inline assembly code into a branch table but I could not figure out how to do it.
I would say it should look something like this. At least the compiler emits something like this for a switch statement. I am using visual studio 2005.
__asm
{
mov eax,BRANCHTABLE
mov ecx,"Number between 0 and N"
jmp [eax+ecx*4]
BRANCHTABLE
&LABLE0
&LABLE1
&LABLE2
...
&LABLEN
LABLE0:
...
LABLE1:
...
LABLE2:
...
...
LABLEN
}
Thanks
|
|
|
|
|