Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
K

kitty5

@kitty5
About
Posts
103
Topics
34
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • SetTimer() & TimerProc [modified]
    K kitty5

    unfortunatly i don't see the WM_TIMER invoke the callback with or without the

    suhredayan® wrote:

    kitty5 wrote: msg.hwnd = hwndTimer;

    grrr.... This should be such a simple task... call SetTimer(1, 1000, TimerProc); is 1000milliseconds pass before the task completes "Pause" if it does complete then disable timer. until it loops back up to the top....

    Kitty5

    C / C++ / MFC c++ help question

  • SetTimer() & TimerProc [modified]
    K kitty5

    Yes, i've tried that also. but I get an Assert error in the wincore.h. I wanted to start a timer before i started doing something. if 1sec has passed then PAUSE. if complete before 1sec then stop timer. HANDLE m_TimerHandle = INVALID_HANDLE_VALUE; void test::OnButtonStart { ... while(something) { int i = 0; ... BOOL success = ::CreateTimerQueueTimer(&m_timerHandle, NULL, TimerProc, this, 0, 1000, WT_EXECUTEONLYONCE); while(i<999999) { i++; } DeleteTimerQueueTimer(NULL, m_timerHandle, NULL); ... } } void test::QueueTimerHandler() { MessageBeep(0xFFFFFFFF); DeleteTimerQueueTimer(NULL, m_timerHandle, NULL); OnButtonPause(); //<-ASSERT Happens after this is completed (it just changes colors on the button) } void CALLBACK TimerProc(void *lpParam, BOOLEAN timeFired) { test *obj = (test*) lpParam; obj->QueueTimerHandler(); }

    Kitty5

    C / C++ / MFC c++ help question

  • SetTimer() &amp; TimerProc [modified]
    K kitty5

    suhredayan® wrote:

    It looks like your while loop does not give the main window thread any chance to process its message queue.

    Actually the code is and I also tried the following: int timer; int i; MSG msg; HWND hwndTimer = (HWND)this; while(something) { timer = SetTimer(1,1000,TimerProc); i = 0; while(i<999999999) { GetMessage(&msg, NULL, 0, 0); if(msg.message == WM_TIMER) msg.hwnd = hwndTimer; // <-It does come here so the timer does get to 1000 TranslateMessage(&msg); DispatchMessage(&msg); i++; } KillTimer(timer); } but it still doesn't execute the TimerProc()

    Kitty5

    C / C++ / MFC c++ help question

  • SetTimer() &amp; TimerProc [modified]
    K kitty5

    Hi, I've created an MDI application that has a tool bar with buttons which open dialog boxes when clicked. One Dialog Box class in this application needs a timer. After reading about CWnd::SetTimer(): UINT_PTR SetTimer(UINT_PTR nIDEvent,UINT uElapse, TIMERPROC lpTimerFunc); I've done the following: test.h: class test : public CDialog { ... afx_msg void OnStart(); ... }; void CALLBACK EXPORT TimerProc( HWND hWnd, // handle of CWnd that called SetTimer UINT nMsg, // WM_TIMER UINT nIDEvent // timer identification DWORD dwTime // system time ); ================================= test.cpp BEGIN_MESSAGE_MAP(test, CDialog) ON_WM_TIMER() END_MESSAGE_MAP() void test::OnStart() { ... int timer; ... timer = SetTimer(1,1000,TimerProc); // 1000 milisecond timer int i = 0; while(i<999999999) { i++; //TIMER SHOULD TIMEOUT IN HERE take about 7sec. } KillTimer(timer);// <-COMES TO THIS POINT ... } void CALLBACK TimerProc( HWND hWnd, // handle of CWnd that called SetTimer UINT nMsg, // WM_TIMER UINT nIDEvent // timer identification DWORD dwTime // system time ) { MessageBeep(0xFFFFFFFF); // Beep MSMPlaybackDlg* pbDlg = NULL; pbDlg->OnButtonHddPause(); KillTimer(hWnd, pbDlg->timer); } the problem is that it doesn't call the TimerProc. It's as if it doesn't timeout after 1000miliseconds. does anyone know what i'm doing wrong?:confused: thanks,

    Kitty5

    C / C++ / MFC c++ help question

  • Communicating dialog boxes
    K kitty5

    Hi everyone. thanks for responding it's been really helpful. with much reading i figured it out and it all makes sense now. I added this to my commanding::load(): ImageViewer *imgViewDlg; imgViewDlg = new ImageViewer(); imgViewDlg->Create(IDD_IMAGEVIEWER, NULL); imgViewDlg->SetWindowPos(NULL, 0, 0, 700, 700,SWP_NOMOVE); imgViewDlg->ShowWindow(SW_SHOW); & then I call the showImage() imgViewDlg->showPicture(buff,numRead); and this seems like it is working. now i'm just looking to see if there's a function for "isWindowActive" or something that i can check if the particular dialog box is inactive because I don't nessesarily want to keep updating the pictures if the window is in the background and someother window is on top of it. thanks!

    Kitty5

    C / C++ / MFC graphics help question

  • Communicating dialog boxes
    K kitty5

    led mike wrote:

    In the first code you posted: void commanding::load(){UpdateData (TRUE);FILE *pic, *pic1, *pic2;picViewer cam1; that instance of picViewer is local to that function so it is not related to anything else.

    oh... really?! hmmm. ok then ummm... how would i be able to open up an instance of the picViewer dialog box in the commanding class and be able to update the bitmaps? i've changed my commanding to: int commanding::loadCmdGet3CamData() { UpdateData (TRUE); FILE *pic, *pic1, *pic2; picViewer cam1; pic = fopen("C:\\cv\\16bit.jp2", "rb"); pic1 = fopen("C:\\cv\\nature_50.jp2", "rb"); pic2 = fopen("C:\\cv\\8_8.jp2", "rb"); unsigned int numRead; **cam1.Create(IDD_IMAGEVIEWER,0); cam1.EnableWindow(TRUE);** int i = 0; while(i < 3) { if(i == 0) numRead = fread(buff, sizeof(BYTE), 100000, pic); else if(i == 1) numRead = fread(buff, sizeof(BYTE), 100000, pic1); else numRead = fread(buff, sizeof(BYTE), 100000, pic2); cam1.showPicture(buff,numRead); //ShowPicture(buff,numRead); i++; Sleep(2000); } fclose(pic); fclose(pic1); fclose(pic2); } thanks,

    Kitty5

    C / C++ / MFC graphics help question

  • Communicating dialog boxes
    K kitty5

    led mike wrote:

    kitty5 wrote: picViewer cam1; If picViewer is a window or dialog it is never being created therefore the CStatic child window is also never created so IsWindow(m_hWnd) returns false and Asserts during debugging.

    picViewer is the class that is related to the picViewer dialog. I added both cam1.Create(IDD_PICVIEWER,0); cam1.EnableWindow(TRUE); to my commanding::load() function. this stops the crashing. however, no picture is shown in the picViewer dialog box even though i call the show(). cam1.show(buff,numRead); Thanks! -- modified at 14:35 Thursday 1st February, 2007

    Kitty5

    C / C++ / MFC graphics help question

  • Communicating dialog boxes
    K kitty5

    I've created 2 classes each with it's own dialog box in an MDI application 1. commanding class 2. picViewer class the commanding class has a func load(). where i create a picViewer variable. void commanding::load() { UpdateData (TRUE); FILE *pic, *pic1, *pic2; **picViewer cam1;** pic = fopen("C:\\cv\\16bit.jp2", "rb"); pic1 = fopen("C:\\cv\\nature_50.jp2", "rb"); pic2 = fopen("C:\\cv\\8_8.jp2", "rb"); unsigned int numRead; int i = 0; while(i < 3) { if(i == 0) numRead = fread(buff, sizeof(BYTE), 100000, pic); else if(i == 1) numRead = fread(buff, sizeof(BYTE), 100000, pic1); else numRead = fread(buff, sizeof(BYTE), 100000, pic2); **cam1.showPicture(buff,numRead);** i++; Sleep(2000); } fclose(pic); fclose(pic1); fclose(pic2); UpdateData (FALSE); } the picViewer class has a func show(). void picViewer::show(BYTE bfr[], DWORD size) { HBITMAP m_bitmap = NULL; CImage image; CJpeg2kDecoder imDec; image = imDec.Open(bfr, size); m_bitmap = (HBITMAP)image; m_nCam1img.SetBitmap(m_bitmap); //m_nCam1img is the var of the picture control in the dialog //box to show the bitmap image. } whenever I run the application i open up both dialog boxes hit run on the commanding dialog box i get an error when i get to "m_nCam1img.SetBitmap(m_bitmap); " which points to: _AFXWIN_INLINE HBITMAP CStatic::SetBitmap(HBITMAP hBitmap) { ASSERT(::IsWindow(m_hWnd)); return (HBITMAP)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap); } in afxwin2.inl what does that mean? what am i doing wrong? what would i need to do in order to show a picture in a separate dialog box? thanks!

    Kitty5

    C / C++ / MFC graphics help question

  • viewing and updating bitmaps
    K kitty5

    ok so I deleted the line: if (m_bitmap) DeleteObject(m_bitmap); but i still have the same problem. is there an update function for the window when the mouse clicks back to view the picture dialog box after the command dialog box was on top of it?

    Kitty5

    C / C++ / MFC graphics question

  • viewing and updating bitmaps
    K kitty5

    m_nCam1img is the variable for the picture control. the if (m_bitmap) DeleteObject(m_bitmap); I thought that that was what you needed to do. I did some research on how to view bmps and all the sample code had that....

    Kitty5

    C / C++ / MFC graphics question

  • viewing and updating bitmaps
    K kitty5

    I've created an MDI application where when I open one dialog it shows a bitmap from my C:/ by: void Image::showPicture(BYTE bfr[], DWORD size) { HBITMAP m_bitmap = NULL; CImage image; CJpeg2kDecoder imDec; image = imDec.Open(bfr, size); m_bitmap = (HBITMAP)image; m_nCam1img.SetBitmap(m_bitmap); if (m_bitmap) DeleteObject(m_bitmap); However, when I open another dialog to do commanding (this dialog will partially cover the bitmap dialog) then go back to view my bitmap the portion of the bitmap dialog covered up by the commanding dialog is GONE! What do i need to do so that when I go back to view the bitmap dialog that the whole picture will still be displayed? Thanks!

    Kitty5

    C / C++ / MFC graphics question

  • Help with MDI Apps with Picture Control
    K kitty5

    WhiteSky, no i do not see a null value of variable because when i come into the showPicture() function the very 1st thing crashes... CPaintDC dc(this); which gives me an error: it crashes and gives this error: Debug Assertion Failed! Program: c:\..\test.exe File: f:\..\ship\atlmfc\src\mfc\wingdi.cpp Line: 1090 Press retry to debug application When I press re-try it goes to this code: ASSERT(::IsWindow(pWnd->m_hWnd)); in wingdi.cpp CPaintDC::CPaintDC(CWnd* pWnd) { ASSERT_VALID(pWnd); ASSERT(::IsWindow(pWnd->m_hWnd)); if (!Attach(::BeginPaint(m_hWnd = pWnd->m_hWnd, &m_ps))) AfxThrowResourceException(); } my reply to James' post: my dialogs are modeless... that's why i thought that this would work. what i'm trying to achieve at the end is to have 3 separate window where we can view pictures from 3 separate cameras we collect data from and 1 dialog box that controls the camera.... if I had just a dialog based app my code works. i simply initialize everything in ::OnInitDialog() and then it has a function called ::OnPaint() that I can call showImage().... It is in an MDI application where everything gets hazy... since it doesn't have an ::OnPaint() or ::OnInitDialog() function. Please advice. thanks, Kitty

    Kitty5

    C / C++ / MFC c++ help question graphics debugging

  • Help with MDI Apps with Picture Control
    K kitty5

    James, I set up the dialogs to be modeless. it's created: void CCameraDataGenTxApp::OnImageViewer() { ImageViewer *imgViewDlg; imgViewDlg = new ImageViewer(); imgViewDlg->Create(IDD_IMAGEVIEWER, NULL); imgViewDlg->SetWindowPos(NULL, 0, 0, 620, 390, SWP_NOMOVE); imgViewDlg->ShowWindow(SW_SHOW); } Called: BEGIN_MESSAGE_MAP(CCameraDataGenTxApp, CWinApp) ON_COMMAND(ID_APP_ABOUT, &CCameraDataGenTxApp::OnAppAbout) // Standard file based document commands ON_COMMAND(ID_FILE_NEW, &CWinApp::OnFileNew) ON_COMMAND(ID_CAMERA, &CCameraDataGenTxApp::OnCamera1Tx) ON_COMMAND(ID_IMGVIEWER, &CCameraDataGenTxApp::OnImageViewer) ON_COMMAND(ID_FILE_OPEN, &CWinApp::OnFileOpen) END_MESSAGE_MAP() that's why i thought that this would work. what i'm trying to achieve at the end is to have 3 separate window where we can view pictures from 3 separate cameras we collect data from and 1 dialog box that controls the camera.... if I had just a dialog based app my code works. i simply initialize everything in ::OnInitDialog() and then it has a function called ::OnPaint() that I can call showImage().... It is in an MDI application where everything gets hazy... :(( since it doesn't have an ::OnPaint() or ::OnInitDialog() function. Please advice. thanks, Kathleen

    Kitty5

    C / C++ / MFC c++ help question graphics debugging

  • Help with MDI Apps with Picture Control
    K kitty5

    James, the following is my imageViewer class: IMPLEMENT_DYNAMIC(ImageViewer, CDialog) ImageViewer::ImageViewer(CWnd* pParent /*=NULL*/) : CDialog(ImageViewer::IDD, pParent) { } ImageViewer::~ImageViewer() { } void ImageViewer::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_CAM1_IMG, m_nCam1img); DDX_Control(pDX, IDOK, m_ok); DDX_Control(pDX, IDCANCEL, m_canc); } BEGIN_MESSAGE_MAP(ImageViewer, CDialog) END_MESSAGE_MAP() BOOL ImageViewer::OnInitDialog() { CDialog::OnInitDialog(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } // ImageViewer message handlers void ImageViewer::showPicture() { CPaintDC dc(this); // device context for painting HBITMAP bmpHandle = (HBITMAP)LoadImage(NULL, "cat.bmp",//strPictureName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION|LR_DEFAULTSIZE); //LR_LOADFROMFILE); CBitmap bmpPicture; CDC mdcPicture; CBitmap *bmpFromHandle = bmpPicture.FromHandle(bmpHandle); CRect rctPicture; m_nCam1img.GetWindowRect(&rctPicture); mdcPicture.CreateCompatibleDC(&dc); CBitmap * bmpPrevious = mdcPicture.SelectObject(bmpFromHandle); ScreenToClient(&rctPicture); dc.BitBlt(rctPicture.left, rctPicture.top, rctPicture.Width(), rctPicture.Height(), &mdcPicture, 0, 0, SRCCOPY); DeleteObject(bmpHandle); } it doesn't have much. i open the dialog for this class before i call the showPicture() i also have break points right now... so any initialization should be complete by then... or am i just confused? thanks,

    Kitty5

    C / C++ / MFC c++ help question graphics debugging

  • Help with MDI Apps with Picture Control
    K kitty5

    Hi, I've created an MDI application in visual C++ 2005. It has 2 dialog resources. 1 is the main resource where the user does things and the other I open manually so that when the code for the 1st dialog gets to the part in the code it will show a BMP picture. I've created a classes for both dialogs. The second dialog class has a function called showPicture(). void ImageViewer::showPicture() { CPaintDC dc(this); // device context for painting HBITMAP bmpHandle = (HBITMAP)LoadImage(NULL, "cat.bmp",//strPictureName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION|LR_DEFAULTSIZE); //LR_LOADFROMFILE); CBitmap bmpPicture; CDC mdcPicture; CBitmap *bmpFromHandle = bmpPicture.FromHandle(bmpHandle); CRect rctPicture; m_nCam1img.GetWindowRect(&rctPicture); mdcPicture.CreateCompatibleDC(&dc); CBitmap * bmpPrevious = mdcPicture.SelectObject(bmpFromHandle); ScreenToClient(&rctPicture); dc.BitBlt(rctPicture.left, rctPicture.top, rctPicture.Width(), rctPicture.Height(), &mdcPicture, 0, 0, SRCCOPY); DeleteObject(bmpHandle); } I call this function in the 1st dialog's class. The program compiles but when I run it and the program gets to the call for the showPicture() function and comes to this line: CPaintDC dc(this); // device context for painting it crashes and gives this error: Debug Assertion Failed! Program: c:\..\test.exe File: f:\..\ship\atlmfc\src\mfc\wingdi.cpp Line: 1090 Press retry to debug application When I press re-try it goes to this code: ASSERT(::IsWindow(pWnd->m_hWnd)); in wingdi.cpp CPaintDC::CPaintDC(CWnd* pWnd) { ASSERT_VALID(pWnd); ASSERT(::IsWindow(pWnd->m_hWnd)); if (!Attach(::BeginPaint(m_hWnd = pWnd->m_hWnd, &m_ps))) AfxThrowResourceException(); } what am i doing wrong? the showPicture() function works fine if i create a single dialog based application.... how can I load/view a bitmap in an MDI application environment? thanks,

    Kitty5

    C / C++ / MFC c++ help question graphics debugging

  • classes and the namespace operator ::
    K kitty5

    :Cedric, thanks very much for your advice. I knew it was something simple that I was missing... thanks! Kitty :-D

    Kitty5

    C / C++ / MFC help

  • classes and the namespace operator ::
    K kitty5

    okey dokey. I have 2 classes: class imageViewer{...}; class camData{...}; imageViewer has a function called funcA(); camData has a function called funcB(); I wanted to call funcA; in funcB(); i.e.:i've tried both: #include "imageViewer.h" void camData::funcB() { .. imageViewer::funcA(); } I get this error: error C2352: 'ImageViewer::showPicture' : illegal call of non-static member function -AND- #include "imageViewer.h" void camData::funcB() { .. funcA(); } I get this error: error C3861: 'showPicture': identifier not found could someone please tell me my idiotic mistake..... thanks, Kitty

    Kitty5

    C / C++ / MFC help

  • CloseHandle() not closing.... [modified]
    K kitty5

    I have created an application(run on win2k) where i communicate with a pci device. Within this application i establish communication by creating a handle to the device. After I've completed the tasks i've set out to do in the application i do: CloseHandle(hdevice); i know that: "CloseHandle invalidates the specified object handle,..." to debug i do: if(!CloseHandle(hdevice)) AfxMessageBox(_T("DEBUG: Handle ::hndlPciAlt:: not closed!")); but i never see this message..... however, from debugging it seems as thought the application was not successful at closing the handle to the device(even when i exit my application). (unless something else is happening...) the reason i say this is when i use a separate test application provided by the manufacturer to reload and reset the FPGA on the device the registers are not being reset. if anyone has any insight on this issue, please advice... thanks in advance, -- modified at 8:58 Friday 3rd November, 2006

    Kitty5

    C / C++ / MFC debugging help

  • One class with Multiple IDDs (is this possible)
    K kitty5

    I've created an MDI application that has test.cpp and test.h in it. I've created an IDD (which is a form) called IDD_TEST and declared it in test.h under the //Dialog Data as: enum { IDD = IDD_TEST }; How does one link multiple IDDs ( i.e. if I create IDD_TEST1 ) to 1 class (test.h and test.cpp) so that the variables and event handlers for the controls of both IDDs are located in test.h and test.cpp and I can use them together. (i.e. if m_nCheckBoxTest is in IDD_TEST and m_nCheckBoxTest1 is in IDD_TEST1 I can do: if(m_nCheckBoxTest.GetCheck() == 1 && m_nCheckBoxTest1.GetCheck() == 1){} The dilema is I can't fit everything into just 1 form for my I&T GUI....(even with scroll bars enabled...) Please help...

    Kitty5

    C / C++ / MFC c++ help

  • Windows 2000 PCI Bus bandwidth
    K kitty5

    I have a PCI/Altera card that I'm communicating with through the PCI bus of my PC with some MDI C++ software that I developed through Visual Studio 2005. I'm not sure if this is the right forum for this but here goes: How does one make sure that the software/GUI gets full control of the PCI Bus bandwidth until it has completed it's task? Is there a function I can call in my C++ program prior to starting any data collection or do I have to set something in the PC OS? In other words, I don't want the Windows 2000 handing over control to other things that want it until my program is completed. I only need about 10-12 secs of control.... Once the executable is running I actually go into task manager and set this process's priority to RealTime. I found this helped with this one PC which is running Windows 2000. However, I tried to see if I can run the same code on a different PC (same OS Windows 2000, and doing the RealTime priority) but it seems as on the original PC what took 9sec to run the new PC it took 14 sec and that's way too long. Needless to say I'm loosing data all over the place.... Please help...:confused:

    Kitty5

    System Admin csharp c++ visual-studio help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups